From 10ddc466bf8cd221a2c088ff2064cd058b51d9a1 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 12 Oct 2018 16:52:13 +0200 Subject: [PATCH 1/2] minor: typo and code style --- src/_pytest/fixtures.py | 5 ++--- src/_pytest/main.py | 7 ++----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index ffaa1b09a..21de82b02 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1013,7 +1013,7 @@ class FixtureFunctionMarker(object): def __call__(self, function): if isclass(function): - raise ValueError("class fixtures not supported (may be in the future)") + raise ValueError("class fixtures not supported (maybe in the future)") if getattr(function, "_pytestfixturefunction", False): raise ValueError( @@ -1366,8 +1366,7 @@ class FixtureManager(object): fixturedefs = self._arg2fixturedefs[argname] except KeyError: return None - else: - return tuple(self._matchfactories(fixturedefs, nodeid)) + return tuple(self._matchfactories(fixturedefs, nodeid)) def _matchfactories(self, fixturedefs, nodeid): for fixturedef in fixturedefs: diff --git a/src/_pytest/main.py b/src/_pytest/main.py index ce07285a4..5ad91dfc4 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -564,9 +564,7 @@ class Session(nodes.FSCollector): return True def _tryconvertpyarg(self, x): - """Convert a dotted module name to path. - - """ + """Convert a dotted module name to path.""" try: with _patched_find_module(): loader = pkgutil.find_loader(x) @@ -598,8 +596,7 @@ class Session(nodes.FSCollector): raise UsageError( "file or package not found: " + arg + " (missing __init__.py?)" ) - else: - raise UsageError("file not found: " + arg) + raise UsageError("file not found: " + arg) parts[0] = path return parts From ee54fb9a6b3d64224059201e6d3a2a238961e6e6 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 13 Oct 2018 17:01:22 +0200 Subject: [PATCH 2/2] pytester: use EXIT_INTERRUPTED --- src/_pytest/pytester.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index a50999172..e3bf060e3 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -19,7 +19,7 @@ from _pytest.capture import MultiCapture, SysCapture from _pytest._code import Source import py import pytest -from _pytest.main import Session, EXIT_OK +from _pytest.main import Session, EXIT_INTERRUPTED, EXIT_OK from _pytest.assertion.rewrite import AssertionRewritingHook from _pytest.compat import Path from _pytest.compat import safe_str @@ -845,7 +845,7 @@ class Testdir(object): # typically we reraise keyboard interrupts from the child run # because it's our user requesting interruption of the testing - if ret == 2 and not kwargs.get("no_reraise_ctrlc"): + if ret == EXIT_INTERRUPTED and not kwargs.get("no_reraise_ctrlc"): calls = reprec.getcalls("pytest_keyboard_interrupt") if calls and calls[-1].excinfo.type == KeyboardInterrupt: raise KeyboardInterrupt()