From ebddac6a5c411cc650fa16382a8115af3aea7409 Mon Sep 17 00:00:00 2001 From: codetriage-readme-bot Date: Tue, 20 Feb 2018 10:51:51 -0600 Subject: [PATCH 01/22] Add CodeTriage badge to pytest-dev/pytest Adds a badge showing the number of people helping this repo on CodeTriage. [![Open Source Helpers](https://www.codetriage.com/pytest-dev/pytest/badges/users.svg)](https://www.codetriage.com/pytest-dev/pytest) ## What is CodeTriage? CodeTriage is an Open Source app that is designed to make contributing to Open Source projects easier. It works by sending subscribers a few open issues in their inbox. If subscribers get busy, there is an algorithm that backs off issue load so they do not get overwhelmed [Read more about the CodeTriage project](https://www.codetriage.com/what). ## Why am I getting this PR? Your project was picked by the human, @schneems. They selected it from the projects submitted to https://www.codetriage.com and hand edited the PR. How did your project get added to [CodeTriage](https://www.codetriage.com/what)? Roughly 11 months ago, [cacoze](https://github.com/cacoze) added this project to CodeTriage in order to start contributing. Since then, 32 people have subscribed to help this repo. ## What does adding a badge accomplish? Adding a badge invites people to help contribute to your project. It also lets developers know that others are invested in the longterm success and maintainability of the project. You can see an example of a CodeTriage badge on these popular OSS READMEs: - [![](https://www.codetriage.com/rails/rails/badges/users.svg)](https://www.codetriage.com/rails/rails) https://github.com/rails/rails - [![](https://www.codetriage.com/crystal-lang/crystal/badges/users.svg)](https://www.codetriage.com/crystal-lang/crystal) https://github.com/crystal-lang/crystal ## Have a question or comment? While I am a bot, this PR was manually reviewed and monitored by a human - @schneems. My job is writing commit messages and handling PR logistics. If you have any questions, you can reply back to this PR and they will be answered by @schneems. If you do not want a badge right now, no worries, close the PR, you will not hear from me again. Thanks for making your project Open Source! Any feedback is greatly appreciated. --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 3630dd4c6..617cad5ac 100644 --- a/README.rst +++ b/README.rst @@ -23,6 +23,8 @@ .. image:: https://ci.appveyor.com/api/projects/status/mrgbjaua7t33pg6b?svg=true :target: https://ci.appveyor.com/project/pytestbot/pytest +.. image:: https://www.codetriage.com/pytest-dev/pytest/badges/users.svg + :target: https://www.codetriage.com/pytest-dev/pytest The ``pytest`` framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries. From 6e14585ca20d27db81f122d2c3a76135e4192fc4 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 20 Feb 2018 22:51:22 +0100 Subject: [PATCH 02/22] Fix approx default tolerances for Decimal --- _pytest/python_api.py | 16 ++++++++++++++-- changelog/3247.bugfix.rst | 1 + testing/python/approx.py | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 changelog/3247.bugfix.rst diff --git a/_pytest/python_api.py b/_pytest/python_api.py index 89ef9e0a9..541371449 100644 --- a/_pytest/python_api.py +++ b/_pytest/python_api.py @@ -153,6 +153,8 @@ class ApproxScalar(ApproxBase): """ Perform approximate comparisons for single numbers only. """ + DEFAULT_ABSOLUTE_TOLERANCE = 1e-12 + DEFAULT_RELATIVE_TOLERANCE = 1e-6 def __repr__(self): """ @@ -223,7 +225,7 @@ class ApproxScalar(ApproxBase): # Figure out what the absolute tolerance should be. ``self.abs`` is # either None or a value specified by the user. - absolute_tolerance = set_default(self.abs, 1e-12) + absolute_tolerance = set_default(self.abs, self.DEFAULT_ABSOLUTE_TOLERANCE) if absolute_tolerance < 0: raise ValueError("absolute tolerance can't be negative: {}".format(absolute_tolerance)) @@ -241,7 +243,7 @@ class ApproxScalar(ApproxBase): # we've made sure the user didn't ask for an absolute tolerance only, # because we don't want to raise errors about the relative tolerance if # we aren't even going to use it. - relative_tolerance = set_default(self.rel, 1e-6) * abs(self.expected) + relative_tolerance = set_default(self.rel, self.DEFAULT_RELATIVE_TOLERANCE) * abs(self.expected) if relative_tolerance < 0: raise ValueError("relative tolerance can't be negative: {}".format(absolute_tolerance)) @@ -252,6 +254,13 @@ class ApproxScalar(ApproxBase): return max(relative_tolerance, absolute_tolerance) +class ApproxDecimal(ApproxScalar): + from decimal import Decimal + + DEFAULT_ABSOLUTE_TOLERANCE = Decimal('1e-12') + DEFAULT_RELATIVE_TOLERANCE = Decimal('1e-6') + + def approx(expected, rel=None, abs=None, nan_ok=False): """ Assert that two numbers (or two sets of numbers) are equal to each other @@ -401,6 +410,7 @@ def approx(expected, rel=None, abs=None, nan_ok=False): from collections import Mapping, Sequence from _pytest.compat import STRING_TYPES as String + from decimal import Decimal # Delegate the comparison to a class that knows how to deal with the type # of the expected value (e.g. int, float, list, dict, numpy.array, etc). @@ -422,6 +432,8 @@ def approx(expected, rel=None, abs=None, nan_ok=False): cls = ApproxMapping elif isinstance(expected, Sequence) and not isinstance(expected, String): cls = ApproxSequence + elif isinstance(expected, Decimal): + cls = ApproxDecimal else: cls = ApproxScalar diff --git a/changelog/3247.bugfix.rst b/changelog/3247.bugfix.rst new file mode 100644 index 000000000..e8091f4e5 --- /dev/null +++ b/changelog/3247.bugfix.rst @@ -0,0 +1 @@ +Fix issue with approx on Decimal value. \ No newline at end of file diff --git a/testing/python/approx.py b/testing/python/approx.py index 300e1ce86..341e5fcff 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -249,6 +249,7 @@ class TestApprox(object): (Decimal('-1.000001'), Decimal('-1.0')), ] for a, x in within_1e6: + assert a == approx(x) assert a == approx(x, rel=Decimal('5e-6'), abs=0) assert a != approx(x, rel=Decimal('5e-7'), abs=0) assert approx(x, rel=Decimal('5e-6'), abs=0) == a From 147b43f83216c612ab0122c8a3961895c4222abe Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 21 Feb 2018 20:31:33 -0300 Subject: [PATCH 03/22] Small changelog tweak --- changelog/3247.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/3247.bugfix.rst b/changelog/3247.bugfix.rst index e8091f4e5..9483ceeea 100644 --- a/changelog/3247.bugfix.rst +++ b/changelog/3247.bugfix.rst @@ -1 +1 @@ -Fix issue with approx on Decimal value. \ No newline at end of file +Fix ``TypeError`` issue when using ``approx`` with a ``Decimal`` value. From 45d0a212945979cc0679ee5b572ccea46386bc3f Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 21 Feb 2018 20:42:09 -0300 Subject: [PATCH 04/22] Fix README because of code triage badge --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 617cad5ac..b2ed1e140 100644 --- a/README.rst +++ b/README.rst @@ -25,6 +25,7 @@ .. image:: https://www.codetriage.com/pytest-dev/pytest/badges/users.svg :target: https://www.codetriage.com/pytest-dev/pytest + The ``pytest`` framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries. From 75f11f0b6576a7bd60927e3425a679c20c40f261 Mon Sep 17 00:00:00 2001 From: Allan Feldman Date: Wed, 21 Feb 2018 19:51:33 -0800 Subject: [PATCH 05/22] Fix reference cycle caused by PseudoFixtureDef. Python types have reference cycles to themselves when they are created. This is partially caused by descriptors which get / set values from the __dict__ attribute for getattr / setattr on classes. This is not normally an issue since types tend to remain referenced for the lifetime of the Python process (and thus never become garbage). However, in the case of PseudoFixtureDef, the class is generated in _get_active_fixturedef and later discarded when pytest_fixture_setup returns. As a result, the generated PseudoFixtureDef type becomes garbage. This is not really a performance issue but it can lead to some problems when making tests and assertions about garbage when using pytest. This garbage creation problem can be rectified by returning a namedtuple instance which is functionally the same. In the modified code, the namedtuple is allocated / deallocated using reference counting rather than having to use the garbage collector. --- _pytest/fixtures.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py index a8445767c..21fc32846 100644 --- a/_pytest/fixtures.py +++ b/_pytest/fixtures.py @@ -4,7 +4,7 @@ import functools import inspect import sys import warnings -from collections import OrderedDict, deque, defaultdict +from collections import OrderedDict, deque, defaultdict, namedtuple import attr import py @@ -23,6 +23,8 @@ from _pytest.compat import ( ) from _pytest.outcomes import fail, TEST_OUTCOME +PseudoFixtureDef = namedtuple('PseudoFixtureDef', ('cached_result', 'scope')) + def pytest_sessionstart(session): import _pytest.python @@ -440,10 +442,9 @@ class FixtureRequest(FuncargnamesCompatAttr): fixturedef = self._getnextfixturedef(argname) except FixtureLookupError: if argname == "request": - class PseudoFixtureDef(object): - cached_result = (self, [0], None) - scope = "function" - return PseudoFixtureDef + cached_result = (self, [0], None) + scope = "function" + return PseudoFixtureDef(cached_result, scope) raise # remove indent to prevent the python3 exception # from leaking into the call From aa53e37fa255248c101f32dda876ad589bc68bb2 Mon Sep 17 00:00:00 2001 From: Allan Feldman Date: Wed, 21 Feb 2018 21:35:35 -0800 Subject: [PATCH 06/22] Add a test to expose leaked PseudoFixtureDef types. --- testing/python/fixture.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/testing/python/fixture.py b/testing/python/fixture.py index 6bcb1ab00..8638e361a 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -519,6 +519,41 @@ class TestRequestBasic(object): assert len(arg2fixturedefs) == 1 assert arg2fixturedefs['something'][0].argname == "something" + def test_request_garbage(self, testdir): + testdir.makepyfile(""" + import sys + import pytest + import gc + + @pytest.fixture(autouse=True) + def something(request): + # this method of test doesn't work on pypy + if hasattr(sys, "pypy_version_info"): + yield + else: + original = gc.get_debug() + gc.set_debug(gc.DEBUG_SAVEALL) + gc.collect() + + yield + + gc.collect() + leaked_types = sum(1 for _ in gc.garbage + if 'PseudoFixtureDef' in str(_)) + + gc.garbage[:] = [] + + try: + assert leaked_types == 0 + finally: + gc.set_debug(original) + + def test_func(): + pass + """) + reprec = testdir.inline_run() + reprec.assertoutcome(passed=1) + def test_getfixturevalue_recursive(self, testdir): testdir.makeconftest(""" import pytest From 287c003cfd28cb2fc0bd4cba92b76333a8543ab7 Mon Sep 17 00:00:00 2001 From: Allan Feldman Date: Wed, 21 Feb 2018 21:56:17 -0800 Subject: [PATCH 07/22] Add myself to AUTHORS. --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index ab646f406..3a564606c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -197,3 +197,4 @@ Xuan Luong Xuecong Liao Zoltán Máté Roland Puntaier +Allan Feldman From 7536e949b18aa6ab5c3594ce9c200aed9dcf8dcb Mon Sep 17 00:00:00 2001 From: Allan Feldman Date: Wed, 21 Feb 2018 22:00:39 -0800 Subject: [PATCH 08/22] Add changelog entry. --- changelog/3249.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/3249.bugfix.rst diff --git a/changelog/3249.bugfix.rst b/changelog/3249.bugfix.rst new file mode 100644 index 000000000..38fa9179f --- /dev/null +++ b/changelog/3249.bugfix.rst @@ -0,0 +1 @@ +Fix reference cycle generated when using the ``request`` fixture. From 48548767fcc1c65134309b649cf4d63f5b9cec65 Mon Sep 17 00:00:00 2001 From: Allan Feldman Date: Wed, 21 Feb 2018 22:59:33 -0800 Subject: [PATCH 09/22] Use a frozen attr class for PseudoFixtureDef. --- _pytest/fixtures.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py index 21fc32846..f9d0ef572 100644 --- a/_pytest/fixtures.py +++ b/_pytest/fixtures.py @@ -4,7 +4,7 @@ import functools import inspect import sys import warnings -from collections import OrderedDict, deque, defaultdict, namedtuple +from collections import OrderedDict, deque, defaultdict import attr import py @@ -23,7 +23,11 @@ from _pytest.compat import ( ) from _pytest.outcomes import fail, TEST_OUTCOME -PseudoFixtureDef = namedtuple('PseudoFixtureDef', ('cached_result', 'scope')) + +@attr.s(frozen=True) +class PseudoFixtureDef(object): + cached_result = attr.ib() + scope = attr.ib() def pytest_sessionstart(session): From b5ac61657a74e2224f2534b7c3663b351bfe2506 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Thu, 22 Feb 2018 13:48:59 -0500 Subject: [PATCH 10/22] Correct docs to config.pluginmanager.get_plugin() `getplugin()` is deprecated in favor of `get_plugin()`. https://github.com/pytest-dev/pytest/blob/dd97c940359079fd874795a731d54d1abb7d4c8e/_pytest/config.py#L261 --- doc/en/writing_plugins.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/writing_plugins.rst b/doc/en/writing_plugins.rst index f5a8ea41e..d88bb8f15 100644 --- a/doc/en/writing_plugins.rst +++ b/doc/en/writing_plugins.rst @@ -278,7 +278,7 @@ the plugin manager like this: .. sourcecode:: python - plugin = config.pluginmanager.getplugin("name_of_plugin") + plugin = config.pluginmanager.get_plugin("name_of_plugin") If you want to look at the names of existing plugins, use the ``--trace-config`` option. From 6166151ee454a7ee1af37db16b5a7909908af5ea Mon Sep 17 00:00:00 2001 From: joshm91 Date: Sat, 24 Feb 2018 19:12:40 +0000 Subject: [PATCH 11/22] Fix minor typo in fixture.rst --- changelog/3259.trivial | 1 + doc/en/fixture.rst | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog/3259.trivial diff --git a/changelog/3259.trivial b/changelog/3259.trivial new file mode 100644 index 000000000..5b5141301 --- /dev/null +++ b/changelog/3259.trivial @@ -0,0 +1 @@ +Fix minor typo in fixture.rst diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index 0828bdcf8..d2b2865ef 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -369,7 +369,7 @@ ends, but ``addfinalizer`` has two key differences over ``yield``: Fixtures can introspect the requesting test context ------------------------------------------------------------- -Fixture function can accept the :py:class:`request ` object +Fixture functions can accept the :py:class:`request ` object to introspect the "requesting" test function, class or module context. Further extending the previous ``smtp`` fixture example, let's read an optional server URL from the test module which uses our fixture:: From 39024a7536b09dd5cf7113f327142291fc8dd265 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 26 Feb 2018 10:56:27 -0300 Subject: [PATCH 12/22] Fix broken links in getting-started Fix #3256 --- doc/en/getting-started.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 4a7284480..31af29da8 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -160,9 +160,9 @@ List the name ``tmpdir`` in the test function signature and ``pytest`` will look PYTEST_TMPDIR/test_needsfiles0 1 failed in 0.12 seconds -More info on tmpdir handling is available at `Temporary directories and files `_. +More info on tmpdir handling is available at :ref:`Temporary directories and files `. -Find out what kind of builtin ```pytest`` fixtures `_ exist with the command:: +Find out what kind of builtin :ref:`pytest fixtures ` exist with the command:: pytest --fixtures # shows builtin and custom fixtures From 46c5d5355ea5127695984b74342c77d23d8858e6 Mon Sep 17 00:00:00 2001 From: feuillemorte Date: Mon, 26 Feb 2018 17:19:58 +0300 Subject: [PATCH 13/22] #3203 Remove progress when no-capture --- _pytest/terminal.py | 2 ++ testing/test_terminal.py | 1 + 2 files changed, 3 insertions(+) diff --git a/_pytest/terminal.py b/_pytest/terminal.py index 51d21cb33..7e034eb9a 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -324,6 +324,8 @@ class TerminalReporter(object): _PROGRESS_LENGTH = len(' [100%]') def _get_progress_information_message(self): + if self.config.getoption('capture') == 'no': + return '' collected = self._session.testscollected if collected: progress = len(self._progress_nodeids_reported) * 100 // collected diff --git a/testing/test_terminal.py b/testing/test_terminal.py index d7fabd055..72a9198a8 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -1045,6 +1045,7 @@ class TestProgress(object): r'test_foo.py \.{5}', r'test_foobar.py \.{5}', ]) + assert "%]" not in output.stdout.str() class TestProgressWithTeardown(object): From 6200920dc388ac8d7822684610ebef7c544341fc Mon Sep 17 00:00:00 2001 From: feuillemorte Date: Mon, 26 Feb 2018 17:24:16 +0300 Subject: [PATCH 14/22] #3203 Added changelog file --- changelog/3203.trivial | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/3203.trivial diff --git a/changelog/3203.trivial b/changelog/3203.trivial new file mode 100644 index 000000000..25d040b39 --- /dev/null +++ b/changelog/3203.trivial @@ -0,0 +1 @@ +Removed progress statistic when capture option is 'no' From 31476c69abaf6f68a160084a6d4501e1535b0bb4 Mon Sep 17 00:00:00 2001 From: feuillemorte Date: Mon, 26 Feb 2018 17:39:32 +0300 Subject: [PATCH 15/22] #3203 Fix tests --- testing/test_terminal.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 72a9198a8..ff4296925 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -1045,6 +1045,8 @@ class TestProgress(object): r'test_foo.py \.{5}', r'test_foobar.py \.{5}', ]) + + output = testdir.runpytest('--capture=no') assert "%]" not in output.stdout.str() From 188df8100c2db0e53b760996a88925ab55973253 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 26 Feb 2018 17:14:28 -0300 Subject: [PATCH 16/22] Small adjustment to the CHANGELOG --- changelog/3203.bugfix.rst | 1 + changelog/3203.trivial | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 changelog/3203.bugfix.rst delete mode 100644 changelog/3203.trivial diff --git a/changelog/3203.bugfix.rst b/changelog/3203.bugfix.rst new file mode 100644 index 000000000..88f357722 --- /dev/null +++ b/changelog/3203.bugfix.rst @@ -0,0 +1 @@ +Removed progress information when capture option is ``no``. diff --git a/changelog/3203.trivial b/changelog/3203.trivial deleted file mode 100644 index 25d040b39..000000000 --- a/changelog/3203.trivial +++ /dev/null @@ -1 +0,0 @@ -Removed progress statistic when capture option is 'no' From 3f7223af443d68c18c90ffc84f58c5f0e9952cb0 Mon Sep 17 00:00:00 2001 From: feuillemorte Date: Tue, 27 Feb 2018 19:02:49 +0300 Subject: [PATCH 17/22] #3260 Fix pytest section in setup ini file --- _pytest/config.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/_pytest/config.py b/_pytest/config.py index d97771155..68d66ee2a 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -1327,10 +1327,17 @@ def determine_setup(inifile, args, warnfunc=None): dirs = get_dirs_from_args(args) if inifile: iniconfig = py.iniconfig.IniConfig(inifile) - try: - inicfg = iniconfig["pytest"] - except KeyError: - inicfg = None + is_cfg_file = '.cfg' in inifile + sections = ['tool:pytest', 'pytest'] if is_cfg_file else ['pytest'] + for section in sections: + try: + inicfg = iniconfig[section] + if is_cfg_file and section == 'pytest' and warnfunc: + from _pytest.deprecated import SETUP_CFG_PYTEST + warnfunc('C1', SETUP_CFG_PYTEST.replace('setup.cfg', inifile)) + break + except KeyError: + inicfg = None rootdir = get_common_ancestor(dirs) else: ancestor = get_common_ancestor(dirs) From eadd15fe4591c4e1c1c949a489cfc53976b5b543 Mon Sep 17 00:00:00 2001 From: feuillemorte Date: Tue, 27 Feb 2018 19:05:53 +0300 Subject: [PATCH 18/22] #3260 Added changelog file --- changelog/3260.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/3260.bugfix diff --git a/changelog/3260.bugfix b/changelog/3260.bugfix new file mode 100644 index 000000000..49dc41c50 --- /dev/null +++ b/changelog/3260.bugfix @@ -0,0 +1 @@ +Fixed ``tool:pytest`` section when setup.cfg passed by option ``-c`` From 409b919fc0cf291b38cabb7eb991b086323e5d1b Mon Sep 17 00:00:00 2001 From: feuillemorte Date: Tue, 27 Feb 2018 19:16:45 +0300 Subject: [PATCH 19/22] #3260 Added test --- testing/test_config.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/testing/test_config.py b/testing/test_config.py index f256b512f..39105f5d6 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -110,6 +110,13 @@ class TestConfigCmdlineParsing(object): config = testdir.parseconfig("-c", "custom.cfg") assert config.getini("custom") == "1" + testdir.makefile(".cfg", custom_tool_pytest_section=""" + [tool:pytest] + custom = 1 + """) + config = testdir.parseconfig("-c", "custom_tool_pytest_section.cfg") + assert config.getini("custom") == "1" + def test_absolute_win32_path(self, testdir): temp_cfg_file = testdir.makefile(".cfg", custom=""" [pytest] From 143ac5af99cc56b1868741b095ad7db7eccde73c Mon Sep 17 00:00:00 2001 From: feuillemorte Date: Tue, 27 Feb 2018 19:26:35 +0300 Subject: [PATCH 20/22] #3260 Fix config.py for py27 --- _pytest/config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/_pytest/config.py b/_pytest/config.py index 68d66ee2a..c84bbe134 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -1327,14 +1327,15 @@ def determine_setup(inifile, args, warnfunc=None): dirs = get_dirs_from_args(args) if inifile: iniconfig = py.iniconfig.IniConfig(inifile) - is_cfg_file = '.cfg' in inifile + is_cfg_file = str(inifile).endswith('.cfg') + # TODO: [pytest] section in *.cfg files is depricated. Need refactoring. sections = ['tool:pytest', 'pytest'] if is_cfg_file else ['pytest'] for section in sections: try: inicfg = iniconfig[section] if is_cfg_file and section == 'pytest' and warnfunc: from _pytest.deprecated import SETUP_CFG_PYTEST - warnfunc('C1', SETUP_CFG_PYTEST.replace('setup.cfg', inifile)) + warnfunc('C1', SETUP_CFG_PYTEST.replace('setup.cfg', str(inifile))) break except KeyError: inicfg = None From 92219e576bcb8d62e0d75e0bf8d10aad58320dde Mon Sep 17 00:00:00 2001 From: feuillemorte Date: Tue, 27 Feb 2018 20:00:46 +0300 Subject: [PATCH 21/22] #3260 Remove deprecation --- _pytest/config.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/_pytest/config.py b/_pytest/config.py index c84bbe134..359cc4bc8 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -1328,14 +1328,10 @@ def determine_setup(inifile, args, warnfunc=None): if inifile: iniconfig = py.iniconfig.IniConfig(inifile) is_cfg_file = str(inifile).endswith('.cfg') - # TODO: [pytest] section in *.cfg files is depricated. Need refactoring. sections = ['tool:pytest', 'pytest'] if is_cfg_file else ['pytest'] for section in sections: try: inicfg = iniconfig[section] - if is_cfg_file and section == 'pytest' and warnfunc: - from _pytest.deprecated import SETUP_CFG_PYTEST - warnfunc('C1', SETUP_CFG_PYTEST.replace('setup.cfg', str(inifile))) break except KeyError: inicfg = None From 1fb2457018d6a2171b2721c84cb7271a6c2c0667 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 27 Feb 2018 14:58:27 -0300 Subject: [PATCH 22/22] Adjust CHANGELOG --- changelog/3260.bugfix | 1 - changelog/3260.bugfix.rst | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 changelog/3260.bugfix create mode 100644 changelog/3260.bugfix.rst diff --git a/changelog/3260.bugfix b/changelog/3260.bugfix deleted file mode 100644 index 49dc41c50..000000000 --- a/changelog/3260.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fixed ``tool:pytest`` section when setup.cfg passed by option ``-c`` diff --git a/changelog/3260.bugfix.rst b/changelog/3260.bugfix.rst new file mode 100644 index 000000000..eb0ecd345 --- /dev/null +++ b/changelog/3260.bugfix.rst @@ -0,0 +1 @@ +``[tool:pytest]`` sections in ``*.cfg`` files passed by the ``-c`` option are now properly recognized.