Upgrade pre-commit hooks except pyupgrade

This commit is contained in:
Anthony Sottile
2018-06-26 06:35:27 -07:00
parent 8133d1955e
commit cbaa7dd56a
86 changed files with 309 additions and 631 deletions

View File

@@ -13,7 +13,6 @@ inf, nan = float("inf"), float("nan")
class MyDocTestRunner(doctest.DocTestRunner):
def __init__(self):
doctest.DocTestRunner.__init__(self)
@@ -26,7 +25,6 @@ class MyDocTestRunner(doctest.DocTestRunner):
class TestApprox(object):
@pytest.fixture
def plus_minus(self):
return u"\u00b1" if sys.version_info[0] > 2 else u"+-"
@@ -34,23 +32,20 @@ class TestApprox(object):
def test_repr_string(self, plus_minus):
tol1, tol2, infr = "1.0e-06", "2.0e-06", "inf"
assert repr(approx(1.0)) == "1.0 {pm} {tol1}".format(pm=plus_minus, tol1=tol1)
assert (
repr(approx([1.0, 2.0]))
== "approx([1.0 {pm} {tol1}, 2.0 {pm} {tol2}])".format(
pm=plus_minus, tol1=tol1, tol2=tol2
)
assert repr(
approx([1.0, 2.0])
) == "approx([1.0 {pm} {tol1}, 2.0 {pm} {tol2}])".format(
pm=plus_minus, tol1=tol1, tol2=tol2
)
assert (
repr(approx((1.0, 2.0)))
== "approx((1.0 {pm} {tol1}, 2.0 {pm} {tol2}))".format(
pm=plus_minus, tol1=tol1, tol2=tol2
)
assert repr(
approx((1.0, 2.0))
) == "approx((1.0 {pm} {tol1}, 2.0 {pm} {tol2}))".format(
pm=plus_minus, tol1=tol1, tol2=tol2
)
assert repr(approx(inf)) == "inf"
assert repr(approx(1.0, rel=nan)) == "1.0 {pm} ???".format(pm=plus_minus)
assert (
repr(approx(1.0, rel=inf))
== "1.0 {pm} {infr}".format(pm=plus_minus, infr=infr)
assert repr(approx(1.0, rel=inf)) == "1.0 {pm} {infr}".format(
pm=plus_minus, infr=infr
)
assert repr(approx(1.0j, rel=inf)) == "1j"

View File

@@ -14,7 +14,6 @@ ignore_parametrized_marks = pytest.mark.filterwarnings(
class TestModule(object):
def test_failing_import(self, testdir):
modcol = testdir.getmodulecol("import alksdjalskdjalkjals")
pytest.raises(Collector.CollectError, modcol.collect)
@@ -141,7 +140,6 @@ class TestModule(object):
class TestClass(object):
def test_class_with_init_warning(self, testdir):
testdir.makepyfile(
"""
@@ -246,7 +244,6 @@ class TestClass(object):
class TestGenerator(object):
def test_generative_functions(self, testdir):
modcol = testdir.getmodulecol(
"""
@@ -458,7 +455,6 @@ class TestGenerator(object):
class TestFunction(object):
def test_getmodulecollector(self, testdir):
item = testdir.getitem("def test_func(): pass")
modcol = item.getparent(pytest.Module)
@@ -673,12 +669,10 @@ class TestFunction(object):
config = item.config
class MyPlugin1(object):
def pytest_pyfunc_call(self, pyfuncitem):
raise ValueError
class MyPlugin2(object):
def pytest_pyfunc_call(self, pyfuncitem):
return True
@@ -831,7 +825,6 @@ class TestFunction(object):
class TestSorting(object):
def test_check_equality(self, testdir):
modcol = testdir.getmodulecol(
"""
@@ -886,7 +879,6 @@ class TestSorting(object):
class TestConftestCustomization(object):
def test_pytest_pycollect_module(self, testdir):
testdir.makeconftest(
"""
@@ -1062,7 +1054,6 @@ def test_modulecol_roundtrip(testdir):
class TestTracebackCutting(object):
def test_skip_simple(self):
excinfo = pytest.raises(pytest.skip.Exception, 'pytest.skip("xxx")')
assert excinfo.traceback[-1].frame.code.name == "skip"
@@ -1191,7 +1182,6 @@ class TestTracebackCutting(object):
class TestReportInfo(object):
def test_itemreport_reportinfo(self, testdir, linecomp):
testdir.makeconftest(
"""
@@ -1497,7 +1487,10 @@ def test_class_injection_does_not_break_collection(testdir):
'''
)
result = testdir.runpytest()
assert "RuntimeError: dictionary changed size during iteration" not in result.stdout.str()
assert (
"RuntimeError: dictionary changed size during iteration"
not in result.stdout.str()
)
result.stdout.fnmatch_lines(["*1 passed*"])

View File

@@ -8,7 +8,6 @@ from _pytest import fixtures
def test_getfuncargnames():
def f():
pass
@@ -30,7 +29,6 @@ def test_getfuncargnames():
assert fixtures.getfuncargnames(h) == ("arg1", "arg2")
class A(object):
def f(self, arg1, arg2="hello"):
pass
@@ -43,7 +41,6 @@ def test_getfuncargnames():
class TestFillFixtures(object):
def test_fillfuncargs_exposed(self):
# used by oejskit, kept for compatibility
assert pytest._fillfuncargs == fixtures.fillfixtures
@@ -570,7 +567,6 @@ class TestFillFixtures(object):
class TestRequestBasic(object):
def test_request_attributes(self, testdir):
item = testdir.getitem(
"""
@@ -1003,7 +999,6 @@ class TestRequestBasic(object):
class TestRequestMarking(object):
def test_applymarker(self, testdir):
item1, item2 = testdir.getitems(
"""
@@ -1073,7 +1068,6 @@ class TestRequestMarking(object):
class TestRequestCachedSetup(object):
def test_request_cachedsetup_defaultmodule(self, testdir):
reprec = testdir.inline_runsource(
"""
@@ -1245,7 +1239,6 @@ class TestRequestCachedSetup(object):
class TestFixtureUsages(object):
def test_noargfixturedec(self, testdir):
testdir.makepyfile(
"""
@@ -1540,7 +1533,6 @@ class TestFixtureUsages(object):
class TestFixtureManagerParseFactories(object):
@pytest.fixture
def testdir(self, request):
testdir = request.getfixturevalue("testdir")
@@ -1668,7 +1660,6 @@ class TestFixtureManagerParseFactories(object):
class TestAutouseDiscovery(object):
@pytest.fixture
def testdir(self, testdir):
testdir.makeconftest(
@@ -1845,7 +1836,6 @@ class TestAutouseDiscovery(object):
class TestAutouseManagement(object):
def test_autouse_conftest_mid_directory(self, testdir):
pkgdir = testdir.mkpydir("xyz123")
pkgdir.join("conftest.py").write(
@@ -2112,7 +2102,6 @@ class TestAutouseManagement(object):
class TestFixtureMarker(object):
def test_parametrize(self, testdir):
testdir.makepyfile(
"""
@@ -2938,21 +2927,18 @@ class TestFixtureMarker(object):
reprec = testdir.inline_run()
reprec.assertoutcome(passed=6)
values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
assert (
values
== [
"test_hello",
"fin John",
"test_hello",
"fin Doe",
"test_name",
"test_population",
"fin John",
"test_name",
"test_population",
"fin Doe",
]
)
assert values == [
"test_hello",
"fin John",
"test_hello",
"fin Doe",
"test_name",
"test_population",
"fin John",
"test_name",
"test_population",
"fin Doe",
]
def test_parametrize_setup_function(self, testdir):
testdir.makepyfile(
@@ -3135,7 +3121,6 @@ class TestRequestScopeAccess(object):
class TestErrors(object):
def test_subfactory_missing_funcarg(self, testdir):
testdir.makepyfile(
"""
@@ -3203,7 +3188,6 @@ class TestErrors(object):
class TestShowFixtures(object):
def test_funcarg_compat(self, testdir):
config = testdir.parseconfigure("--funcargs")
assert config.option.showfixtures
@@ -3480,7 +3464,6 @@ class TestShowFixtures(object):
@pytest.mark.parametrize("flavor", ["fixture", "yield_fixture"])
class TestContextManagerFixtureFuncs(object):
def test_simple(self, testdir, flavor):
testdir.makepyfile(
"""
@@ -3622,7 +3605,6 @@ class TestContextManagerFixtureFuncs(object):
class TestParameterizedSubRequest(object):
def test_call_from_fixture(self, testdir):
testfile = testdir.makepyfile(
"""

View File

@@ -4,7 +4,6 @@ from _pytest import runner
class TestOEJSKITSpecials(object):
def test_funcarg_non_pycollectobj(self, testdir): # rough jstests usage
testdir.makeconftest(
"""
@@ -70,7 +69,6 @@ class TestOEJSKITSpecials(object):
def test_wrapped_getfslineno():
def func():
pass
@@ -89,12 +87,10 @@ def test_wrapped_getfslineno():
class TestMockDecoration(object):
def test_wrapped_getfuncargnames(self):
from _pytest.compat import getfuncargnames
def wrap(f):
def func():
pass
@@ -115,7 +111,6 @@ class TestMockDecoration(object):
from _pytest.compat import getfuncargnames
def wrap(f):
def func():
pass
@@ -269,7 +264,6 @@ class TestMockDecoration(object):
class TestReRunTests(object):
def test_rerun(self, testdir):
testdir.makeconftest(
"""
@@ -316,7 +310,6 @@ def test_pytestconfig_is_session_scoped():
class TestNoselikeTestAttribute(object):
def test_module_with_global_test(self, testdir):
testdir.makepyfile(
"""
@@ -402,7 +395,6 @@ class TestNoselikeTestAttribute(object):
@pytest.mark.issue351
class TestParameterize(object):
def test_idfn_marker(self, testdir):
testdir.makepyfile(
"""

View File

@@ -14,7 +14,6 @@ PY3 = sys.version_info >= (3, 0)
class TestMetafunc(object):
def Metafunc(self, func, config=None):
# the unit tests of this class check if things work correctly
# on the funcarg level, so we don't need a full blown
@@ -35,7 +34,6 @@ class TestMetafunc(object):
return python.Metafunc(definition, fixtureinfo, config)
def test_no_funcargs(self, testdir):
def function():
pass
@@ -44,7 +42,6 @@ class TestMetafunc(object):
repr(metafunc._calls)
def test_function_basic(self):
def func(arg1, arg2="qwe"):
pass
@@ -55,7 +52,6 @@ class TestMetafunc(object):
assert metafunc.cls is None
def test_addcall_no_args(self):
def func(arg1):
pass
@@ -67,7 +63,6 @@ class TestMetafunc(object):
assert not hasattr(call, "param")
def test_addcall_id(self):
def func(arg1):
pass
@@ -83,7 +78,6 @@ class TestMetafunc(object):
assert metafunc._calls[1].id == "2"
def test_addcall_param(self):
def func(arg1):
pass
@@ -101,7 +95,6 @@ class TestMetafunc(object):
assert metafunc._calls[2].getparam("arg1") == 1
def test_addcall_funcargs(self):
def func(x):
pass
@@ -119,7 +112,6 @@ class TestMetafunc(object):
assert not hasattr(metafunc._calls[1], "param")
def test_parametrize_error(self):
def func(x, y):
pass
@@ -132,7 +124,6 @@ class TestMetafunc(object):
pytest.raises(ValueError, lambda: metafunc.parametrize("y", [5, 6]))
def test_parametrize_bad_scope(self, testdir):
def func(x):
pass
@@ -143,7 +134,6 @@ class TestMetafunc(object):
assert "has an unsupported scope value 'doggy'" in str(ve)
def test_parametrize_and_id(self):
def func(x, y):
pass
@@ -166,7 +156,6 @@ class TestMetafunc(object):
assert ids == [u"basic", u"advanced"]
def test_parametrize_with_wrong_number_of_ids(self, testdir):
def func(x, y):
pass
@@ -185,12 +174,10 @@ class TestMetafunc(object):
@pytest.mark.issue510
def test_parametrize_empty_list(self):
def func(y):
pass
class MockConfig(object):
def getini(self, name):
return ""
@@ -206,7 +193,6 @@ class TestMetafunc(object):
assert "skip" == metafunc._calls[0].marks[0].name
def test_parametrize_with_userobjects(self):
def func(x, y):
pass
@@ -338,23 +324,20 @@ class TestMetafunc(object):
pytest.param(b"\xc3\xb4", totext("other")),
],
)
assert (
result
== [
"1.0--1.1",
"2--202",
"three-three hundred",
"True-False",
"None-None",
"foo-bar",
"str-int",
"a7-b7",
"a8-b8",
"a9-b9",
"\\xc3\\xb4-name",
"\\xc3\\xb4-other",
]
)
assert result == [
"1.0--1.1",
"2--202",
"three-three hundred",
"True-False",
"None-None",
"foo-bar",
"str-int",
"a7-b7",
"a8-b8",
"a9-b9",
"\\xc3\\xb4-name",
"\\xc3\\xb4-other",
]
def test_idmaker_enum(self):
from _pytest.python import idmaker
@@ -424,23 +407,20 @@ class TestMetafunc(object):
idfn=ids,
)
assert (
[str(i.message) for i in rec.list]
== [
"Raised while trying to determine id of parameter a at position 0."
"\nUpdate your code as this will raise an error in pytest-4.0.",
"Raised while trying to determine id of parameter b at position 0."
"\nUpdate your code as this will raise an error in pytest-4.0.",
"Raised while trying to determine id of parameter a at position 1."
"\nUpdate your code as this will raise an error in pytest-4.0.",
"Raised while trying to determine id of parameter b at position 1."
"\nUpdate your code as this will raise an error in pytest-4.0.",
"Raised while trying to determine id of parameter a at position 2."
"\nUpdate your code as this will raise an error in pytest-4.0.",
"Raised while trying to determine id of parameter b at position 2."
"\nUpdate your code as this will raise an error in pytest-4.0.",
]
)
assert [str(i.message) for i in rec.list] == [
"Raised while trying to determine id of parameter a at position 0."
"\nUpdate your code as this will raise an error in pytest-4.0.",
"Raised while trying to determine id of parameter b at position 0."
"\nUpdate your code as this will raise an error in pytest-4.0.",
"Raised while trying to determine id of parameter a at position 1."
"\nUpdate your code as this will raise an error in pytest-4.0.",
"Raised while trying to determine id of parameter b at position 1."
"\nUpdate your code as this will raise an error in pytest-4.0.",
"Raised while trying to determine id of parameter a at position 2."
"\nUpdate your code as this will raise an error in pytest-4.0.",
"Raised while trying to determine id of parameter b at position 2."
"\nUpdate your code as this will raise an error in pytest-4.0.",
]
def test_parametrize_ids_exception(self, testdir):
"""
@@ -496,7 +476,6 @@ class TestMetafunc(object):
assert result == ["a0", "a1", "b0", "c", "b1"]
def test_addcall_and_parametrize(self):
def func(x, y):
pass
@@ -511,7 +490,6 @@ class TestMetafunc(object):
@pytest.mark.issue714
def test_parametrize_indirect(self):
def func(x, y):
pass
@@ -526,7 +504,6 @@ class TestMetafunc(object):
@pytest.mark.issue714
def test_parametrize_indirect_list(self):
def func(x, y):
pass
@@ -537,7 +514,6 @@ class TestMetafunc(object):
@pytest.mark.issue714
def test_parametrize_indirect_list_all(self):
def func(x, y):
pass
@@ -548,7 +524,6 @@ class TestMetafunc(object):
@pytest.mark.issue714
def test_parametrize_indirect_list_empty(self):
def func(x, y):
pass
@@ -588,7 +563,6 @@ class TestMetafunc(object):
@pytest.mark.issue714
def test_parametrize_indirect_list_error(self, testdir):
def func(x, y):
pass
@@ -704,7 +678,6 @@ class TestMetafunc(object):
)
def test_addcalls_and_parametrize_indirect(self):
def func(x, y):
pass
@@ -837,7 +810,6 @@ class TestMetafunc(object):
)
def test_format_args(self):
def function1():
pass
@@ -860,7 +832,6 @@ class TestMetafunc(object):
class TestMetafuncFunctional(object):
def test_attributes(self, testdir):
p = testdir.makepyfile(
"""
@@ -1494,7 +1465,6 @@ class TestMetafuncFunctionalAuto(object):
@pytest.mark.filterwarnings("ignore:Applying marks directly to parameters")
@pytest.mark.issue308
class TestMarkersWithParametrization(object):
def test_simple_mark(self, testdir):
s = """
import pytest

View File

@@ -4,7 +4,6 @@ import sys
class TestRaises(object):
def test_raises(self):
source = "int('qwe')"
excinfo = pytest.raises(ValueError, source)
@@ -22,9 +21,7 @@ class TestRaises(object):
pytest.raises(ValueError, int, "hello")
def test_raises_callable_no_exception(self):
class A(object):
def __call__(self):
pass
@@ -109,7 +106,6 @@ class TestRaises(object):
import gc
class T(object):
def __call__(self):
raise ValueError
@@ -160,7 +156,6 @@ class TestRaises(object):
from six import add_metaclass
class Meta(type(object)):
def __getitem__(self, item):
return 1 / 0