diff --git a/Makefile b/Makefile index 4b73c06..d72e744 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ install: ## Install package for development @pip install -r requirements-dev.txt test: - @py.test tests/ --cov pytest_testdox --cov-report=xml + @pytest tests/ --cov pytest_testdox --cov-report=xml check: ## Run static code checks isort --check diff --git a/pytest_testdox/formatters.py b/pytest_testdox/formatters.py index edaab7e..f3cf628 100644 --- a/pytest_testdox/formatters.py +++ b/pytest_testdox/formatters.py @@ -34,7 +34,7 @@ def _remove_patterns(statement, patterns): pattern = '{0}$'.format(pattern) statement = re.sub(pattern, '', statement) - elif glob_pattern.endswith('*'): + elif glob_pattern.endswith('*'): pattern = '^{0}'.format(pattern) statement = re.sub(pattern, '', statement) diff --git a/pytest_testdox/models.py b/pytest_testdox/models.py index 8384610..2a7b1ed 100644 --- a/pytest_testdox/models.py +++ b/pytest_testdox/models.py @@ -41,14 +41,17 @@ def parse(cls, nodeid, pattern_config): pattern_config.files ) - class_name = node_parts[-2] - if '()' not in class_name: - class_name = None - else: + class_name = None + if '()' in node_parts[-2]: class_name = formatters.format_class_name( node_parts[-3], pattern_config.classes ) + elif len(node_parts) > 2: + class_name = formatters.format_class_name( + node_parts[-2], + pattern_config.classes + ) return cls(title=title, class_name=class_name, module_name=module_name) diff --git a/pytest_testdox/plugin.py b/pytest_testdox/plugin.py index e338576..3e2a084 100644 --- a/pytest_testdox/plugin.py +++ b/pytest_testdox/plugin.py @@ -56,7 +56,10 @@ def _register_stats(self, report): Originally from: https://github.com/pytest-dev/pytest/blob/47a2a77/_pytest/terminal.py#L198-L201 """ - res = self.config.hook.pytest_report_teststatus(report=report) + res = self.config.hook.pytest_report_teststatus( + report=report, + config=self.config + ) category = res[0] self.stats.setdefault(category, []).append(report) self._tests_ran = True diff --git a/tests/test_models.py b/tests/test_models.py index 09076af..4340db6 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -44,6 +44,10 @@ def test_parse_should_parse_node_id_attributes(self, pattern_config): ( 'tests/test_module.py::TestClassName::()::test_title', formatters.format_class_name('TestClassName', ['Test*']) + ), + ( + 'tests/test_module.py::TestClassName::test_title', + formatters.format_class_name('TestClassName', ['Test*']) ) )) def test_parse_with_class_name(self, pattern_config, nodeid, class_name):