From cfaf3600c1d9ea2b45d9b801a47379304fd7e455 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 27 Feb 2018 03:38:56 -0500 Subject: [PATCH 1/8] Consolidate behavior by using filterfalse and always_iterable --- _pytest/python_api.py | 15 ++++++--------- setup.py | 1 + 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/_pytest/python_api.py b/_pytest/python_api.py index 541371449..3dce7f6b4 100644 --- a/_pytest/python_api.py +++ b/_pytest/python_api.py @@ -2,7 +2,8 @@ import math import sys import py -from six.moves import zip +from six.moves import zip, filterfalse +from more_itertools.more import always_iterable from _pytest.compat import isclass from _pytest.outcomes import fail @@ -566,14 +567,10 @@ def raises(expected_exception, *args, **kwargs): """ __tracebackhide__ = True - msg = ("exceptions must be old-style classes or" - " derived from BaseException, not %s") - if isinstance(expected_exception, tuple): - for exc in expected_exception: - if not isclass(exc): - raise TypeError(msg % type(exc)) - elif not isclass(expected_exception): - raise TypeError(msg % type(expected_exception)) + for exc in filterfalse(isclass, always_iterable(expected_exception)): + msg = ("exceptions must be old-style classes or" + " derived from BaseException, not %s") + raise TypeError(msg % type(exc)) message = "DID NOT RAISE {0}".format(expected_exception) match_expr = None diff --git a/setup.py b/setup.py index 30234d2cc..78f082913 100644 --- a/setup.py +++ b/setup.py @@ -60,6 +60,7 @@ def main(): 'six>=1.10.0', 'setuptools', 'attrs>=17.2.0', + 'more_itertools>=4.0.0', ] # if _PYTEST_SETUP_SKIP_PLUGGY_DEP is set, skip installing pluggy; # used by tox.ini to test with pluggy master From 14a9b1ec838fc1b2bb530458757c0bb9a67f164d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 28 Feb 2018 17:31:11 -0300 Subject: [PATCH 2/8] Add CHANGELOG for #3265 --- changelog/3265.trivial.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/3265.trivial.rst diff --git a/changelog/3265.trivial.rst b/changelog/3265.trivial.rst new file mode 100644 index 000000000..b4ad22ecf --- /dev/null +++ b/changelog/3265.trivial.rst @@ -0,0 +1 @@ +``pytest`` now depends on the `more_itertools `_ package. From 30453057e88de4274d6d4e7532eb89da723d4825 Mon Sep 17 00:00:00 2001 From: Maik Figura Date: Sat, 3 Mar 2018 23:50:13 +0100 Subject: [PATCH 3/8] Add logging plugin to plugins list --- _pytest/logging.py | 1 + changelog/3209.doc | 1 + doc/en/plugins.rst | 1 + 3 files changed, 3 insertions(+) create mode 100644 changelog/3209.doc diff --git a/_pytest/logging.py b/_pytest/logging.py index f6affc8a2..6d9274d1a 100644 --- a/_pytest/logging.py +++ b/_pytest/logging.py @@ -1,3 +1,4 @@ +""" Access and control log capturing. """ from __future__ import absolute_import, division, print_function import logging diff --git a/changelog/3209.doc b/changelog/3209.doc new file mode 100644 index 000000000..84e165805 --- /dev/null +++ b/changelog/3209.doc @@ -0,0 +1 @@ +Add logging plugin to plugins list. \ No newline at end of file diff --git a/doc/en/plugins.rst b/doc/en/plugins.rst index 400418aee..2a9fff81b 100644 --- a/doc/en/plugins.rst +++ b/doc/en/plugins.rst @@ -148,6 +148,7 @@ in the `pytest repository `_. _pytest.resultlog _pytest.runner _pytest.main + _pytest.logging _pytest.skipping _pytest.terminal _pytest.tmpdir From 46f5d7a1bb7edc6883e6141d1d272a4db4be8cc0 Mon Sep 17 00:00:00 2001 From: Maik Figura Date: Sun, 4 Mar 2018 00:52:27 +0100 Subject: [PATCH 4/8] Add filetype to changelog fragment --- changelog/{3209.doc => 3209.doc.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{3209.doc => 3209.doc.rst} (100%) diff --git a/changelog/3209.doc b/changelog/3209.doc.rst similarity index 100% rename from changelog/3209.doc rename to changelog/3209.doc.rst From 056d9e8dc232229fc9c0e86b26d43f9c000656fa Mon Sep 17 00:00:00 2001 From: Maik Figura Date: Sun, 4 Mar 2018 00:55:04 +0100 Subject: [PATCH 5/8] Use `isdir` instead of `exists` --- _pytest/main.py | 2 +- changelog/3241.bugfix.rst | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelog/3241.bugfix.rst diff --git a/_pytest/main.py b/_pytest/main.py index 1caa7ff1e..f2d4b0155 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -170,7 +170,7 @@ def _in_venv(path): """Attempts to detect if ``path`` is the root of a Virtual Environment by checking for the existence of the appropriate activate script""" bindir = path.join('Scripts' if sys.platform.startswith('win') else 'bin') - if not bindir.exists(): + if not bindir.isdir(): return False activates = ('activate', 'activate.csh', 'activate.fish', 'Activate', 'Activate.bat', 'Activate.ps1') diff --git a/changelog/3241.bugfix.rst b/changelog/3241.bugfix.rst new file mode 100644 index 000000000..32d85c2b8 --- /dev/null +++ b/changelog/3241.bugfix.rst @@ -0,0 +1,2 @@ +Refactor check of bindir from `exists` to `isdir`. + From 9a2e0c061d0a51c6a4f08c8b8f609fd04ac10ce7 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 3 Mar 2018 23:14:57 -0300 Subject: [PATCH 6/8] Update 3241.bugfix.rst --- changelog/3241.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/3241.bugfix.rst b/changelog/3241.bugfix.rst index 32d85c2b8..2b8b07d83 100644 --- a/changelog/3241.bugfix.rst +++ b/changelog/3241.bugfix.rst @@ -1,2 +1,2 @@ -Refactor check of bindir from `exists` to `isdir`. +Refactor check of bindir from ``exists`` to ``isdir`` regarding `#3241 `_. From 65534682aaa659354efda5c582015066e92bd4db Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 4 Mar 2018 10:56:24 -0300 Subject: [PATCH 7/8] Revert introduction of more_itertools This was merged on master but really should be on features: we should not add new dependencies in bug-fix releases This reverts commits: * cfaf3600c1d9ea2b45d9b801a47379304fd7e455 * 14a9b1ec838fc1b2bb530458757c0bb9a67f164d --- _pytest/python_api.py | 15 +++++++++------ changelog/3265.trivial.rst | 1 - setup.py | 1 - 3 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 changelog/3265.trivial.rst diff --git a/_pytest/python_api.py b/_pytest/python_api.py index 3dce7f6b4..541371449 100644 --- a/_pytest/python_api.py +++ b/_pytest/python_api.py @@ -2,8 +2,7 @@ import math import sys import py -from six.moves import zip, filterfalse -from more_itertools.more import always_iterable +from six.moves import zip from _pytest.compat import isclass from _pytest.outcomes import fail @@ -567,10 +566,14 @@ def raises(expected_exception, *args, **kwargs): """ __tracebackhide__ = True - for exc in filterfalse(isclass, always_iterable(expected_exception)): - msg = ("exceptions must be old-style classes or" - " derived from BaseException, not %s") - raise TypeError(msg % type(exc)) + msg = ("exceptions must be old-style classes or" + " derived from BaseException, not %s") + if isinstance(expected_exception, tuple): + for exc in expected_exception: + if not isclass(exc): + raise TypeError(msg % type(exc)) + elif not isclass(expected_exception): + raise TypeError(msg % type(expected_exception)) message = "DID NOT RAISE {0}".format(expected_exception) match_expr = None diff --git a/changelog/3265.trivial.rst b/changelog/3265.trivial.rst deleted file mode 100644 index b4ad22ecf..000000000 --- a/changelog/3265.trivial.rst +++ /dev/null @@ -1 +0,0 @@ -``pytest`` now depends on the `more_itertools `_ package. diff --git a/setup.py b/setup.py index 78f082913..30234d2cc 100644 --- a/setup.py +++ b/setup.py @@ -60,7 +60,6 @@ def main(): 'six>=1.10.0', 'setuptools', 'attrs>=17.2.0', - 'more_itertools>=4.0.0', ] # if _PYTEST_SETUP_SKIP_PLUGGY_DEP is set, skip installing pluggy; # used by tox.ini to test with pluggy master From 25399da9047d044174f090f1315f9a4244b91135 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 4 Mar 2018 10:59:46 -0300 Subject: [PATCH 8/8] Reintroduce more_itertools dependency Reintroduce more_itertools that was added in #3265, now in the features branch --- _pytest/python_api.py | 15 ++++++--------- changelog/3265.trivial.rst | 1 + setup.py | 1 + 3 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 changelog/3265.trivial.rst diff --git a/_pytest/python_api.py b/_pytest/python_api.py index 541371449..3dce7f6b4 100644 --- a/_pytest/python_api.py +++ b/_pytest/python_api.py @@ -2,7 +2,8 @@ import math import sys import py -from six.moves import zip +from six.moves import zip, filterfalse +from more_itertools.more import always_iterable from _pytest.compat import isclass from _pytest.outcomes import fail @@ -566,14 +567,10 @@ def raises(expected_exception, *args, **kwargs): """ __tracebackhide__ = True - msg = ("exceptions must be old-style classes or" - " derived from BaseException, not %s") - if isinstance(expected_exception, tuple): - for exc in expected_exception: - if not isclass(exc): - raise TypeError(msg % type(exc)) - elif not isclass(expected_exception): - raise TypeError(msg % type(expected_exception)) + for exc in filterfalse(isclass, always_iterable(expected_exception)): + msg = ("exceptions must be old-style classes or" + " derived from BaseException, not %s") + raise TypeError(msg % type(exc)) message = "DID NOT RAISE {0}".format(expected_exception) match_expr = None diff --git a/changelog/3265.trivial.rst b/changelog/3265.trivial.rst new file mode 100644 index 000000000..b4ad22ecf --- /dev/null +++ b/changelog/3265.trivial.rst @@ -0,0 +1 @@ +``pytest`` now depends on the `more_itertools `_ package. diff --git a/setup.py b/setup.py index 78b3ebc5e..1cbabd72e 100644 --- a/setup.py +++ b/setup.py @@ -60,6 +60,7 @@ def main(): 'six>=1.10.0', 'setuptools', 'attrs>=17.4.0', + 'more_itertools>=4.0.0', ] # if _PYTEST_SETUP_SKIP_PLUGGY_DEP is set, skip installing pluggy; # used by tox.ini to test with pluggy master