From 6d0bae0d3e52ca68b4ef4d80bcf13123ca871573 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 21 Aug 2017 17:16:47 -0400 Subject: [PATCH] - santitize brackets / periods from classnames for junitxml Change-Id: I1071bd70fd4166937b07536725f0900cba03d86b --- alembic/testing/plugin/plugin_base.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/alembic/testing/plugin/plugin_base.py b/alembic/testing/plugin/plugin_base.py index 31f34e2b..7b27e69e 100644 --- a/alembic/testing/plugin/plugin_base.py +++ b/alembic/testing/plugin/plugin_base.py @@ -412,7 +412,16 @@ def generate_sub_tests(cls, module): if getattr(cls, '__backend__', False): for cfg in _possible_configs_for_cls(cls): orig_name = cls.__name__ - name = "%s_%s" % (cls.__name__, cfg.name) + + # we can have special chars in these names except for the + # pytest junit plugin, which is tripped up by the brackets + # and periods, so sanitize + + alpha_name = re.sub('[_\[\]\.]+', '_', cfg.name) + alpha_name = re.sub('_+$', '', alpha_name) + name = "%s_%s" % (cls.__name__, alpha_name) + + subcls = type( name, (cls, ), -- 2.47.2