From 7248b759e88ff282cab5bf289d4d7047ef0bfaad Mon Sep 17 00:00:00 2001 From: Andras Tim Date: Mon, 17 Jul 2017 01:25:09 +0200 Subject: [PATCH] Fixed E303 flake8 errors too many blank lines (3) --- _pytest/assertion/__init__.py | 1 - _pytest/assertion/rewrite.py | 3 --- _pytest/cacheprovider.py | 1 - _pytest/compat.py | 2 -- _pytest/config.py | 1 - _pytest/debugging.py | 1 - _pytest/fixtures.py | 7 ------- _pytest/freeze_support.py | 1 - _pytest/main.py | 2 -- _pytest/mark.py | 4 ---- _pytest/pytester.py | 1 - _pytest/python.py | 2 -- _pytest/terminal.py | 1 - testing/acceptance_test.py | 3 --- testing/code/test_excinfo.py | 3 --- testing/code/test_source.py | 1 - testing/python/collect.py | 4 ---- testing/python/fixture.py | 8 -------- testing/python/metafunc.py | 5 ----- testing/python/raises.py | 1 - testing/test_cache.py | 4 ---- testing/test_capture.py | 2 -- testing/test_collection.py | 1 - testing/test_config.py | 1 - testing/test_doctest.py | 1 - testing/test_mark.py | 2 -- testing/test_pdb.py | 2 -- testing/test_recwarn.py | 1 - testing/test_skipping.py | 1 - testing/test_terminal.py | 1 - testing/test_warnings.py | 1 - tox.ini | 2 +- 32 files changed, 1 insertion(+), 70 deletions(-) diff --git a/_pytest/assertion/__init__.py b/_pytest/assertion/__init__.py index acb034d86..b0ef667d5 100644 --- a/_pytest/assertion/__init__.py +++ b/_pytest/assertion/__init__.py @@ -25,7 +25,6 @@ def pytest_addoption(parser): expression information.""") - def register_assert_rewrite(*names): """Register one or more module names to be rewritten on import. diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py index 48f5d4388..97663ccda 100644 --- a/_pytest/assertion/rewrite.py +++ b/_pytest/assertion/rewrite.py @@ -215,8 +215,6 @@ class AssertionRewritingHook(object): raise return sys.modules[name] - - def is_package(self, name): try: fd, fn, desc = imp.find_module(name) @@ -900,7 +898,6 @@ class AssertionRewriter(ast.NodeVisitor): else: visit_Call = visit_Call_legacy - def visit_Attribute(self, attr): if not isinstance(attr.ctx, ast.Load): return self.generic_visit(attr) diff --git a/_pytest/cacheprovider.py b/_pytest/cacheprovider.py index 31cfb2a29..6378e4338 100755 --- a/_pytest/cacheprovider.py +++ b/_pytest/cacheprovider.py @@ -180,7 +180,6 @@ def pytest_cmdline_main(config): return wrap_session(config, cacheshow) - @pytest.hookimpl(tryfirst=True) def pytest_configure(config): config.cache = Cache(config) diff --git a/_pytest/compat.py b/_pytest/compat.py index bebcc71f9..cdca56387 100644 --- a/_pytest/compat.py +++ b/_pytest/compat.py @@ -13,7 +13,6 @@ import py import _pytest - try: import enum except ImportError: # pragma: no cover @@ -111,7 +110,6 @@ def getfuncargnames(function, startindex=None): return tuple(argnames[startindex:]) - if sys.version_info[:2] == (2, 6): def isclass(object): """ Return true if the object is a class. Overrides inspect.isclass for diff --git a/_pytest/config.py b/_pytest/config.py index 7d299b30f..d2d3c8439 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -851,7 +851,6 @@ class DropShorterLongHelpFormatter(argparse.HelpFormatter): return action._formatted_action_invocation - def _ensure_removed_sysmodule(modname): try: del sys.modules[modname] diff --git a/_pytest/debugging.py b/_pytest/debugging.py index 1d69cd0ad..aa9c9a386 100644 --- a/_pytest/debugging.py +++ b/_pytest/debugging.py @@ -4,7 +4,6 @@ import pdb import sys - def pytest_addoption(parser): group = parser.getgroup("general") group._addoption( diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py index 67cf7e39e..50c2b95f8 100644 --- a/_pytest/fixtures.py +++ b/_pytest/fixtures.py @@ -116,7 +116,6 @@ def add_funcarg_pseudo_fixture_def(collector, metafunc, fixturemanager): node._name2pseudofixturedef[argname] = fixturedef - def getfixturemarker(obj): """ return fixturemarker or None if it doesn't exist or raised exceptions.""" @@ -128,7 +127,6 @@ def getfixturemarker(obj): return None - def get_parametrized_fixture_keys(item, scopenum): """ return list of keys for all parametrized arguments which match the specified scope. """ @@ -240,7 +238,6 @@ def fillfixtures(function): request._fillfixtures() - def get_direct_param_fixture_func(request): return request.param @@ -283,7 +280,6 @@ class FixtureRequest(FuncargnamesCompatAttr): """ underlying collection node (depends on current request scope)""" return self._getscopeitem(self.scope) - def _getnextfixturedef(self, argname): fixturedefs = self._arg2fixturedefs.get(argname, None) if fixturedefs is None: @@ -305,7 +301,6 @@ class FixtureRequest(FuncargnamesCompatAttr): """ the pytest config object associated with this request. """ return self._pyfuncitem.config - @scopeproperty() def function(self): """ test function object if the request has a per-function scope. """ @@ -839,7 +834,6 @@ class FixtureFunctionMarker: return function - def fixture(scope="function", params=None, autouse=False, ids=None, name=None): """ (return a) decorator to mark a fixture factory function. @@ -955,7 +949,6 @@ class FixtureManager: self._nodeid_and_autousenames = [("", self.config.getini("usefixtures"))] session.config.pluginmanager.register(self, "funcmanage") - def getfixtureinfo(self, node, func, cls, funcargs=True): if funcargs and not hasattr(node, "nofuncargs"): if cls is not None: diff --git a/_pytest/freeze_support.py b/_pytest/freeze_support.py index 52f86087f..97147a882 100644 --- a/_pytest/freeze_support.py +++ b/_pytest/freeze_support.py @@ -5,7 +5,6 @@ pytest from __future__ import absolute_import, division, print_function - def freeze_includes(): """ Returns a list of module names used by py.test that should be diff --git a/_pytest/main.py b/_pytest/main.py index b9850b8b6..97d7e0c71 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -77,7 +77,6 @@ def pytest_addoption(parser): help="base temporary directory for this test run.") - def pytest_namespace(): """keeping this one works around a deeper startup issue in pytest @@ -217,7 +216,6 @@ class _CompatProperty(object): return getattr(__import__('pytest'), self.name) - class NodeKeywords(MappingMixin): def __init__(self, node): self.node = node diff --git a/_pytest/mark.py b/_pytest/mark.py index 88642a000..67086ae8b 100644 --- a/_pytest/mark.py +++ b/_pytest/mark.py @@ -245,7 +245,6 @@ class MarkGenerator: on the ``test_function`` object. """ _config = None - def __getattr__(self, name): if name[0] == "_": raise AttributeError("Marker name must NOT start with underscore") @@ -356,9 +355,6 @@ class MarkDecorator: return self.__class__(self.mark.combined_with(mark)) - - - class Mark(namedtuple('Mark', 'name, args, kwargs')): def combined_with(self, other): diff --git a/_pytest/pytester.py b/_pytest/pytester.py index 12473231d..1783c9c0c 100644 --- a/_pytest/pytester.py +++ b/_pytest/pytester.py @@ -390,7 +390,6 @@ class RunResult: assert failed == d.get("failed", 0) - class Testdir: """Temporary test directory with tools to test/run pytest itself. diff --git a/_pytest/python.py b/_pytest/python.py index 39dd5394a..47759ecee 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -48,7 +48,6 @@ def filter_traceback(entry): return p != cutdir1 and not p.relto(cutdir2) and not p.relto(cutdir3) - def pyobj_property(name): def get(self): node = self.getparent(getattr(__import__('pytest'), name)) @@ -193,7 +192,6 @@ def pytest_make_parametrize_id(config, val, argname=None): return None - class PyobjContext(object): module = pyobj_property("Module") cls = pyobj_property("Class") diff --git a/_pytest/terminal.py b/_pytest/terminal.py index fdf909042..10f37c6a1 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -509,7 +509,6 @@ class TerminalReporter: content = content[:-1] self._tw.line(content) - def summary_failures(self): if self.config.option.tbstyle != "no": reports = self.getreports('failed') diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 4426c068e..9a75a43e5 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -81,7 +81,6 @@ class TestGeneralUsage(object): "*---unconfigure", ]) - def test_config_preparse_plugin_option(self, testdir): testdir.makepyfile(pytest_xyz=""" def pytest_addoption(parser): @@ -147,7 +146,6 @@ class TestGeneralUsage(object): *ERROR*could not load*conftest.py* """) - def test_early_skip(self, testdir): testdir.mkdir("xyz") testdir.makeconftest(""" @@ -676,7 +674,6 @@ class TestInvocationVariants(object): import _pytest.config assert type(_pytest.config.get_plugin_manager()) is _pytest.config.PytestPluginManager - def test_has_plugin(self, request): """Test hasplugin function of the plugin manager (#932).""" assert request.config.pluginmanager.hasplugin('python') diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 48ef6e7e8..966ef192d 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -467,7 +467,6 @@ class TestFormattedExcinfo(object): 'E AssertionError' ] - def test_repr_source_not_existing(self): pr = FormattedExcinfo() co = compile("raise ValueError()", "", "exec") @@ -553,14 +552,12 @@ raise ValueError() if py.std.sys.version_info[0] >= 3: assert repr.chain[0][0].reprentries[0].lines[0] == "> ???" - fail = py.error.ENOENT # noqa repr = pr.repr_excinfo(excinfo) assert repr.reprtraceback.reprentries[0].lines[0] == "> ???" if py.std.sys.version_info[0] >= 3: assert repr.chain[0][0].reprentries[0].lines[0] == "> ???" - def test_repr_local(self): p = FormattedExcinfo(showlocals=True) loc = {'y': 5, 'z': 7, 'x': 3, '@x': 2, '__builtins__': {}} diff --git a/testing/code/test_source.py b/testing/code/test_source.py index e9732d7f3..f7f272c7b 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -642,7 +642,6 @@ finally: assert str(source) == " raise IndexError(1)" - class TestIf(object): pytestmark = astonly source = """\ diff --git a/testing/python/collect.py b/testing/python/collect.py index a36997513..a7e632018 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -476,7 +476,6 @@ class TestFunction(object): rec = testdir.inline_run() rec.assertoutcome(passed=2) - def test_parametrize_with_non_hashable_values_indirect(self, testdir): """Test parametrization with non-hashable values with indirect parametrization.""" testdir.makepyfile(""" @@ -504,7 +503,6 @@ class TestFunction(object): rec = testdir.inline_run() rec.assertoutcome(passed=2) - def test_parametrize_overrides_fixture(self, testdir): """Test parametrization when parameter overrides existing fixture with same name.""" testdir.makepyfile(""" @@ -532,7 +530,6 @@ class TestFunction(object): rec = testdir.inline_run() rec.assertoutcome(passed=3) - def test_parametrize_overrides_parametrized_fixture(self, testdir): """Test parametrization when parameter overrides existing parametrized fixture with same name.""" testdir.makepyfile(""" @@ -1352,7 +1349,6 @@ def test_skip_duplicates_by_default(testdir): ]) - def test_keep_duplicates(testdir): """Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609) diff --git a/testing/python/fixture.py b/testing/python/fixture.py index 19cfabd20..ba6e94bf0 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -441,7 +441,6 @@ class TestFillFixtures(object): ]) assert "INTERNAL" not in result.stdout.str() - def test_fixture_excinfo_leak(self, testdir): # on python2 sys.excinfo would leak into fixture executions testdir.makepyfile(""" @@ -641,7 +640,6 @@ class TestRequestBasic(object): mod = reprec.getcalls("pytest_runtest_setup")[0].item.module assert not mod.l - def test_request_addfinalizer_partial_setup_failure(self, testdir): p = testdir.makepyfile(""" import pytest @@ -1603,8 +1601,6 @@ class TestAutouseManagement(object): reprec = testdir.inline_run() reprec.assertoutcome(passed=2) - - def test_funcarg_and_setup(self, testdir): testdir.makepyfile(""" import pytest @@ -2406,7 +2402,6 @@ class TestFixtureMarker(object): reprec = testdir.inline_run("-v") reprec.assertoutcome(passed=5) - @pytest.mark.issue246 @pytest.mark.parametrize("scope", ["session", "function", "module"]) def test_finalizer_order_on_parametrization(self, scope, testdir): @@ -2638,8 +2633,6 @@ class TestErrors(object): *3 pass*2 error* """) - - def test_setupfunc_missing_funcarg(self, testdir): testdir.makepyfile(""" import pytest @@ -2747,7 +2740,6 @@ class TestShowFixtures(object): """) - def test_show_fixtures_different_files(self, testdir): """ #833: --fixtures only shows fixtures from first file diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 8c0bf41d0..fef4221f3 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -331,7 +331,6 @@ class TestMetafunc(object): "\nUpdate your code as this will raise an error in pytest-4.0.", ] - def test_parametrize_ids_exception(self, testdir): """ :param testdir: the instance of Testdir class, a temporary @@ -776,7 +775,6 @@ class TestMetafuncFunctional(object): result = testdir.runpytest(p) result.assert_outcomes(passed=1) - def test_generate_plugin_and_module(self, testdir): testdir.makeconftest(""" def pytest_generate_tests(metafunc): @@ -1435,7 +1433,6 @@ class TestMarkersWithParametrization(object): reprec = testdir.inline_run() reprec.assertoutcome(passed=2, skipped=2) - @pytest.mark.issue290 def test_parametrize_ID_generation_string_int_works(self, testdir): testdir.makepyfile(""" @@ -1452,7 +1449,6 @@ class TestMarkersWithParametrization(object): reprec = testdir.inline_run() reprec.assertoutcome(passed=2) - @pytest.mark.parametrize('strict', [True, False]) def test_parametrize_marked_value(self, testdir, strict): s = """ @@ -1476,7 +1472,6 @@ class TestMarkersWithParametrization(object): passed, failed = (0, 2) if strict else (2, 0) reprec.assertoutcome(passed=passed, failed=failed) - def test_pytest_make_parametrize_id(self, testdir): testdir.makeconftest(""" def pytest_make_parametrize_id(config, val): diff --git a/testing/python/raises.py b/testing/python/raises.py index 21a6f808c..321ee349e 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -118,7 +118,6 @@ class TestRaises(object): for o in gc.get_objects(): assert type(o) is not T - def test_raises_match(self): msg = r"with base \d+" with pytest.raises(ValueError, match=msg): diff --git a/testing/test_cache.py b/testing/test_cache.py index 231a4e53d..1a570e2c3 100755 --- a/testing/test_cache.py +++ b/testing/test_cache.py @@ -89,7 +89,6 @@ class TestNewAPI(object): result.stdout.fnmatch_lines(["*1 passed*"]) - def test_cache_reportheader(testdir): testdir.makepyfile(""" def test_hello(): @@ -339,7 +338,6 @@ class TestLastFailed(object): lastfailed = rlf(fail_import=0, fail_run=1) assert list(lastfailed) == ['test_maybe.py::test_hello'] - def test_lastfailed_failure_subset(self, testdir, monkeypatch): testdir.makepyfile(test_maybe=""" @@ -381,12 +379,10 @@ class TestLastFailed(object): result, lastfailed = rlf(fail_import=1, fail_run=0) assert sorted(list(lastfailed)) == ['test_maybe.py', 'test_maybe2.py'] - result, lastfailed = rlf(fail_import=0, fail_run=0, args=('test_maybe2.py',)) assert list(lastfailed) == ['test_maybe.py'] - # edge case of test selection - even if we remember failures # from other tests we still need to run all tests if no test # matches the failures diff --git a/testing/test_capture.py b/testing/test_capture.py index 326596ee5..302a02d10 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -49,7 +49,6 @@ def oswritebytes(fd, obj): os.write(fd, tobytes(obj)) - def StdCaptureFD(out=True, err=True, in_=True): return capture.MultiCapture(out, err, in_, Capture=capture.FDCapture) @@ -1076,7 +1075,6 @@ def test_close_and_capture_again(testdir): """) - @pytest.mark.parametrize('method', ['SysCapture', 'FDCapture']) def test_capturing_and_logging_fundamentals(testdir, method): if method == "StdCaptureFD" and not hasattr(os, 'dup'): diff --git a/testing/test_collection.py b/testing/test_collection.py index 56a985bf1..05d9244a0 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -69,7 +69,6 @@ class TestCollector(object): parent = fn.getparent(pytest.Class) assert parent is cls - def test_getcustomfile_roundtrip(self, testdir): hello = testdir.makefile(".xxx", hello="world") testdir.makepyfile(conftest=""" diff --git a/testing/test_config.py b/testing/test_config.py index 7c6b7d6bc..495821cd5 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -731,7 +731,6 @@ class TestOverrideIniArgs(object): assert result.ret == 0 result.stdout.fnmatch_lines(["custom_option:3.0"]) - def test_override_ini_pathlist(self, testdir): testdir.makeconftest(""" def pytest_addoption(parser): diff --git a/testing/test_doctest.py b/testing/test_doctest.py index dfbab28cc..dd444569c 100644 --- a/testing/test_doctest.py +++ b/testing/test_doctest.py @@ -294,7 +294,6 @@ class TestDoctests(object): "*:5: DocTestFailure" ]) - def test_txtfile_failing(self, testdir): p = testdir.maketxtfile(""" >>> i = 0 diff --git a/testing/test_mark.py b/testing/test_mark.py index 4e05d5a5c..f0fc375b8 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -462,7 +462,6 @@ class TestFunctional(object): items, rec = testdir.inline_genitems(p) self.assert_markers(items, test_foo=('a', 'b'), test_bar=('a',)) - @pytest.mark.issue568 @pytest.mark.xfail(reason="markers smear on methods of base classes") def test_mark_should_not_pass_to_siebling_class(self, testdir): @@ -487,7 +486,6 @@ class TestFunctional(object): assert not hasattr(base_item.obj, 'b') assert not hasattr(sub_item_other.obj, 'b') - def test_mark_decorator_baseclasses_merged(self, testdir): p = testdir.makepyfile(""" import pytest diff --git a/testing/test_pdb.py b/testing/test_pdb.py index b6543b053..70a5c3c5b 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -33,7 +33,6 @@ def custom_pdb_calls(): return called - class TestPDB(object): @pytest.fixture @@ -377,7 +376,6 @@ class TestPDB(object): ]) assert custom_pdb_calls == ["init", "reset", "interaction"] - def test_pdb_custom_cls_without_pdb(self, testdir, custom_pdb_calls): p1 = testdir.makepyfile("""xxx """) result = testdir.runpytest_inprocess( diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py index f1048f07d..e8b1db399 100644 --- a/testing/test_recwarn.py +++ b/testing/test_recwarn.py @@ -295,7 +295,6 @@ class TestWarns(object): assert str(record[0].message) == "user" assert str(record[1].message) == "runtime" - def test_double_test(self, testdir): """If a test is run again, the warning should still be raised""" testdir.makepyfile(''' diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 586244f23..b780e4dc8 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -350,7 +350,6 @@ class TestXFail(object): "*1 xfailed*", ]) - @pytest.mark.parametrize('expected, actual, matchline', [('TypeError', 'TypeError', "*1 xfailed*"), ('(AttributeError, TypeError)', 'TypeError', "*1 xfailed*"), diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 43028fc46..bac3ab8b1 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -734,7 +734,6 @@ class TestGenericReporting(object): "*2 failed*", ]) - def test_tb_option(self, testdir, option): testdir.makepyfile(""" import pytest diff --git a/testing/test_warnings.py b/testing/test_warnings.py index 09693662c..858932846 100644 --- a/testing/test_warnings.py +++ b/testing/test_warnings.py @@ -113,7 +113,6 @@ def test_ignore(testdir, pyfile_with_warnings, method): assert WARNINGS_SUMMARY_HEADER not in result.stdout.str() - @pytest.mark.skipif(sys.version_info < (3, 0), reason='warnings message is unicode is ok in python3') def test_unicode(testdir, pyfile_with_warnings): diff --git a/tox.ini b/tox.ini index 8479b2586..3c3f89055 100644 --- a/tox.ini +++ b/tox.ini @@ -196,6 +196,6 @@ filterwarnings = ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning [flake8] -ignore = E303,E401,E402,E501,E701,E702,E704,E712,E731 +ignore = E401,E402,E501,E701,E702,E704,E712,E731 max-line-length = 120 exclude = _pytest/vendored_packages/pluggy.py