diff --git a/README.md b/README.md index b6dcf76..c1c8004 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@

pytest-spec

- @@ -45,9 +44,15 @@ ### spec_header_format -You can configure the format of the test headers by specifying a [format string](https://docs.python.org/2/library/string.html#format-string-syntax) in your [ini-file](http://doc.pytest.org/en/latest/customize.html#inifiles): +You can configure the format of the test headers by specifying a [format string](https://docs.python.org/2/library/string.html#format-string-syntax) in your [ini-file](https://docs.pytest.org/en/stable/customize.html#pytest-ini): + ```ini + ; since pytest 4.6.x + [pytest] + spec_header_format = {module_path}: + + ; legacy pytest [tool:pytest] spec_header_format = {module_path}: ``` @@ -56,7 +61,7 @@ In addition to the ``{path}`` and ``{class_name}`` replacement fields, there is ### spec_test_format -You can configure the format of the test results by specifying a [format string](https://docs.python.org/2/library/string.html#format-string-syntax) in your [ini-file](http://doc.pytest.org/en/latest/customize.html#inifiles): +You can configure the format of the test results by specifying a [format string](https://docs.python.org/2/library/string.html#format-string-syntax) in your [ini-file](https://docs.pytest.org/en/stable/customize.html#pytest-ini): 3 variables are available: * result - place for indicator @@ -64,6 +69,11 @@ You can configure the format of the test results by specifying a [format string] * docstring_summary - first line from test docstring if available ```ini + ; since pytest 4.6.x + [pytest] + spec_test_format = {result} {name} + + ; legacy pytest [tool:pytest] spec_test_format = {result} {name} ``` @@ -71,6 +81,11 @@ You can configure the format of the test results by specifying a [format string] or ```ini + ; since pytest 4.6.x + [pytest] + spec_test_format = {result} {docstring_summary} + + ; legacy pytest [tool:pytest] spec_test_format = {result} {docstring_summary} ``` @@ -82,6 +97,11 @@ In second example where docstring is not available the name will be added to spe You can configure the indicator displayed when test passed. ```ini + ; since pytest 4.6.x + [pytest] + spec_success_indicator = ✓ + + ; legacy pytest [tool:pytest] spec_success_indicator = ✓ ``` @@ -91,6 +111,11 @@ You can configure the indicator displayed when test passed. You can configure the indicator displated when test failed. ```ini + ; since pytest 4.6.x + [pytest] + spec_failure_indicator = ✗ + + ; legacy pytest [tool:pytest] spec_failure_indicator = ✗ ``` @@ -100,6 +125,11 @@ You can configure the indicator displated when test failed. You can configure the indicator displated when test is skipped. ```ini + ; since pytest 4.6.x + [pytest] + spec_skipped_indicator = ? + + ; legacy pytest [tool:pytest] spec_skipped_indicator = ? ``` @@ -110,6 +140,11 @@ Comma-separated settings to ignore/hide some tests or output from from plugins l Any test which contain provided string will be ignored in output spec. ```ini + ; since pytest 4.6.x + [pytest] + spec_ignore = FLAKE8 + + ; legacy pytest [tool:pytest] spec_ignore = FLAKE8 ``` @@ -117,6 +152,11 @@ Any test which contain provided string will be ignored in output spec. ### spec_indent ```ini + ; since pytest 4.6.x + [pytest] + spec_indent = " " + + ; legacy pytest [tool:pytest] spec_indent = " " ``` diff --git a/pyproject.toml b/pyproject.toml index ca689f9..08ebe3e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,8 +12,8 @@ classifiers = [ "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", @@ -30,10 +30,9 @@ packages = [ include = ["LICENSE.txt"] [tool.poetry.dependencies] -six = "*" +python = ">=3.5" [tool.poetry.dev-dependencies] -mock = ">1.0.1" pytest = "*" pytest-describe = "*" pytest-flake8 = "*" diff --git a/pytest_spec/__init__.py b/pytest_spec/__init__.py index 55ea5f7..141763d 100644 --- a/pytest_spec/__init__.py +++ b/pytest_spec/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ :author: Pawel Chomicki """ diff --git a/pytest_spec/patch.py b/pytest_spec/patch.py index 2110e82..a39ccce 100644 --- a/pytest_spec/patch.py +++ b/pytest_spec/patch.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """Module contains method that will be replaced by the plugin. :author: Pawel Chomicki @@ -183,7 +182,7 @@ def _get_test_name(nodeid): test_name_parts = test_name.split(' ') if len(test_name_parts) == 1: return test_name.strip().capitalize() - return 'The ({0}) {1}'.format(test_name_parts[0][1:].replace(' ', '_'), test_name_parts[1]) + return 'The ({}) {}'.format(test_name_parts[0][1:].replace(' ', '_'), test_name_parts[1]) return test_name diff --git a/pytest_spec/plugin.py b/pytest_spec/plugin.py index 08c76ff..f32e3b3 100644 --- a/pytest_spec/plugin.py +++ b/pytest_spec/plugin.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """Module contains command line option definition and logic needed to enable new formatting. :author: Pawel Chomicki @@ -57,12 +56,12 @@ def pytest_addoption(parser): def pytest_configure(config): if getattr(config.option, 'spec', 0) and not getattr(config.option, 'quiet', 0) and not getattr(config.option, 'verbose', 0): - import six + import importlib import _pytest _pytest.terminal.TerminalReporter.pytest_runtest_logstart = logstart_replacer _pytest.terminal.TerminalReporter.pytest_runtest_logreport = report_replacer _pytest.terminal.TerminalReporter.pytest_collection_modifyitems = modifyitems_replacer - six.moves.reload_module(_pytest) + importlib.reload(_pytest) @pytest.mark.hookwrapper diff --git a/pytest_spec/replacer.py b/pytest_spec/replacer.py index 8d81184..83a6f0a 100644 --- a/pytest_spec/replacer.py +++ b/pytest_spec/replacer.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """Module contains method for replace operation. Additional method are necessary because self is not yet defined and module diff --git a/test/test_formats/test_describe_format.py b/test/test_formats/test_describe_format.py index 602c9a5..adc1070 100644 --- a/test/test_formats/test_describe_format.py +++ b/test/test_formats/test_describe_format.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ :author: Pawel Chomicki :e-mail: pawel.chomicki@gmail.com diff --git a/test/test_formats/test_functions.py b/test/test_formats/test_functions.py index 020d401..4763bf9 100644 --- a/test/test_formats/test_functions.py +++ b/test/test_formats/test_functions.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ :author: Pawel Chomicki :e-mail: pawel.chomicki@gmail.com diff --git a/test/test_formats/test_methods.py b/test/test_formats/test_methods.py index 077e178..09cc005 100644 --- a/test/test_formats/test_methods.py +++ b/test/test_formats/test_methods.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ :author: Pawel Chomicki :e-mail: pawel.chomicki@gmail.com @@ -6,7 +5,7 @@ import unittest -class SomeClass(object): +class SomeClass: def some_method(self, arg): return arg diff --git a/test/test_patch.py b/test/test_patch.py index 05ec407..df7956d 100644 --- a/test/test_patch.py +++ b/test/test_patch.py @@ -1,16 +1,15 @@ -# -*- coding: utf-8 -*- """ :author: Pawel Chomicki """ import unittest -from mock import Mock, call +from unittest.mock import Mock, call import pytest_spec from pytest_spec.patch import pytest_runtest_logstart, pytest_runtest_logreport -class FakeHook(object): +class FakeHook: def __init__(self, *args, **kwargs): self.cat = kwargs.get('cat', ' ') self.letter = kwargs.get('letter', ' ') @@ -20,7 +19,7 @@ def pytest_report_teststatus(self, report, config): return self.cat, self.letter, self.word -class FakeConfig(object): +class FakeConfig: def __init__(self, *args, **kwargs): self.hook = FakeHook(*args, **kwargs) @@ -43,12 +42,12 @@ def getini(self, option): return result -class FakeStats(object): +class FakeStats: def setdefault(self, first, second): return [] -class FakeSelf(object): +class FakeSelf: def __init__(self, *args, **kwargs): self.config = FakeConfig(*args, **kwargs) self.currentfspath = None @@ -56,7 +55,7 @@ def __init__(self, *args, **kwargs): self.stats = FakeStats() -class FakeReport(object): +class FakeReport: def __init__(self, nodeid, *args, **kwargs): self.nodeid = nodeid self.passed = kwargs.get('passed', True) diff --git a/test/test_plugin.py b/test/test_plugin.py index 2bcaec4..0d27972 100755 --- a/test/test_plugin.py +++ b/test/test_plugin.py @@ -1,20 +1,19 @@ -# -*- coding: utf-8 -*- """ :author: Pawel Chomicki """ import unittest -from mock import Mock, call, patch +from unittest.mock import Mock, call, patch from pytest_spec.plugin import pytest_addoption, pytest_configure -class FakeOption(object): +class FakeOption: def __init__(self, spec=False): self.spec = spec self.verbose = 0 -class FakeConfig(object): +class FakeConfig: def __init__(self, spec): self.option = FakeOption(spec=spec) @@ -34,12 +33,12 @@ def test__pytest_adoption__adds_spec_option(self): dest='spec', help='Print test result in specification format')]) - @patch('six.moves.reload_module') + @patch('importlib.reload') def test__pytest_configure__should_not_reload_configuration(self, imp_mock): pytest_configure(FakeConfig(spec=False)) self.assertEqual(len(imp_mock.mock_calls), 0) - @patch('six.moves.reload_module') + @patch('importlib.reload') def test__pytest_configure__reloads_pytest_after_patching(self, imp_mock): pytest_configure(FakeConfig(spec=True)) self.assertEqual(len(imp_mock.mock_calls), 1) diff --git a/test/test_replacer.py b/test/test_replacer.py index 9526bc1..1106cdf 100644 --- a/test/test_replacer.py +++ b/test/test_replacer.py @@ -1,10 +1,9 @@ -# -*- coding: utf-8 -*- """ :author: Pawel Chomicki """ import unittest -from mock import patch +from unittest.mock import patch from pytest_spec.replacer import logstart_replacer, report_replacer diff --git a/test/test_results/test_as_class.py b/test/test_results/test_as_class.py index 5445dec..2ffeb60 100644 --- a/test/test_results/test_as_class.py +++ b/test/test_results/test_as_class.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ :author: Pawel Chomicki :e-mail: pawel.chomicki@gmail.com diff --git a/test/test_results/test_as_functions.py b/test/test_results/test_as_functions.py index f725e61..5154531 100644 --- a/test/test_results/test_as_functions.py +++ b/test/test_results/test_as_functions.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ :author: Pawel Chomicki :e-mail: pawel.chomicki@gmail.com