diff options
Diffstat (limited to 'testing')
-rw-r--r-- | testing/acceptance_test.py | 4 | ||||
-rw-r--r-- | testing/code/test_excinfo.py | 4 | ||||
-rw-r--r-- | testing/deprecated_test.py | 2 | ||||
-rw-r--r-- | testing/logging/test_reporting.py | 8 | ||||
-rw-r--r-- | testing/python/approx.py | 2 | ||||
-rw-r--r-- | testing/python/fixture.py | 18 | ||||
-rw-r--r-- | testing/python/metafunc.py | 6 | ||||
-rw-r--r-- | testing/python/raises.py | 6 | ||||
-rw-r--r-- | testing/test_assertion.py | 12 | ||||
-rw-r--r-- | testing/test_config.py | 2 | ||||
-rw-r--r-- | testing/test_doctest.py | 10 | ||||
-rw-r--r-- | testing/test_junitxml.py | 6 | ||||
-rw-r--r-- | testing/test_mark.py | 6 | ||||
-rw-r--r-- | testing/test_parseopt.py | 2 |
14 files changed, 44 insertions, 44 deletions
diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 8ceb3bae1..711e5a86c 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -599,8 +599,8 @@ class TestInvocationVariants(object): "__import__('pkg_resources').declare_namespace(__name__)") lib = ns.mkdir(dirname) lib.ensure("__init__.py") - lib.join("test_{0}.py".format(dirname)). \ - write("def test_{0}(): pass\n" + lib.join("test_{}.py".format(dirname)). \ + write("def test_{}(): pass\n" "def test_other():pass".format(dirname)) # The structure of the test directory is now: diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 8fd59423f..0f044c9f5 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -203,8 +203,8 @@ class TestTraceback_f_g_h(object): excinfo = pytest.raises(ValueError, h) traceback = excinfo.traceback ntraceback = traceback.filter() - print('old: {0!r}'.format(traceback)) - print('new: {0!r}'.format(ntraceback)) + print('old: {!r}'.format(traceback)) + print('new: {!r}'.format(ntraceback)) if matching: assert len(ntraceback) == len(traceback) - 2 diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index cb66472c9..2f354e817 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -126,7 +126,7 @@ def test_terminal_reporter_writer_attr(pytestconfig): def test_pytest_catchlog_deprecated(testdir, plugin): testdir.makepyfile(""" def test_func(pytestconfig): - pytestconfig.pluginmanager.register(None, 'pytest_{0}') + pytestconfig.pluginmanager.register(None, 'pytest_{}') """.format(plugin)) res = testdir.runpytest() assert res.ret == 0 diff --git a/testing/logging/test_reporting.py b/testing/logging/test_reporting.py index 699df0e60..6e3f9c07b 100644 --- a/testing/logging/test_reporting.py +++ b/testing/logging/test_reporting.py @@ -596,7 +596,7 @@ def test_log_file_cli(testdir): log_file = testdir.tmpdir.join('pytest.log').strpath - result = testdir.runpytest('-s', '--log-file={0}'.format(log_file), '--log-file-level=WARNING') + result = testdir.runpytest('-s', '--log-file={}'.format(log_file), '--log-file-level=WARNING') # fnmatch_lines does an assertion internally result.stdout.fnmatch_lines([ @@ -628,7 +628,7 @@ def test_log_file_cli_level(testdir): log_file = testdir.tmpdir.join('pytest.log').strpath result = testdir.runpytest('-s', - '--log-file={0}'.format(log_file), + '--log-file={}'.format(log_file), '--log-file-level=INFO') # fnmatch_lines does an assertion internally @@ -661,7 +661,7 @@ def test_log_file_ini(testdir): testdir.makeini( """ [pytest] - log_file={0} + log_file={} log_file_level=WARNING """.format(log_file)) testdir.makepyfile(''' @@ -697,7 +697,7 @@ def test_log_file_ini_level(testdir): testdir.makeini( """ [pytest] - log_file={0} + log_file={} log_file_level = INFO """.format(log_file)) testdir.makepyfile(''' diff --git a/testing/python/approx.py b/testing/python/approx.py index 9ca21bdf8..6ebe2e512 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -375,7 +375,7 @@ class TestApprox(object): expected = '4.0e-06' result = testdir.runpytest() result.stdout.fnmatch_lines([ - '*At index 0 diff: 3 != 4 * {0}'.format(expected), + '*At index 0 diff: 3 != 4 * {}'.format(expected), '=* 1 failed in *=', ]) diff --git a/testing/python/fixture.py b/testing/python/fixture.py index d9f08a3f0..d8af217cf 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -1749,7 +1749,7 @@ class TestAutouseManagement(object): def test_2(self): pass """) - confcut = "--confcutdir={0}".format(testdir.tmpdir) + confcut = "--confcutdir={}".format(testdir.tmpdir) reprec = testdir.inline_run("-v", "-s", confcut) reprec.assertoutcome(passed=8) config = reprec.getcalls("pytest_unconfigure")[0].config @@ -3132,9 +3132,9 @@ class TestParameterizedSubRequest(object): E*Failed: The requested fixture has no parameter defined for the current test. E* E*Requested fixture 'fix_with_param' defined in: - E*{0}:4 + E*{}:4 E*Requested here: - E*{1}:9 + E*{}:9 *1 error* """.format(testfile.basename, testfile.basename)) @@ -3154,9 +3154,9 @@ class TestParameterizedSubRequest(object): E*Failed: The requested fixture has no parameter defined for the current test. E* E*Requested fixture 'fix_with_param' defined in: - E*{0}:4 + E*{}:4 E*Requested here: - E*{1}:8 + E*{}:8 *1 failed* """.format(testfile.basename, testfile.basename)) @@ -3178,9 +3178,9 @@ class TestParameterizedSubRequest(object): E*Failed: The requested fixture has no parameter defined for the current test. E* E*Requested fixture 'fix_with_param' defined in: - E*{0}:4 + E*{}:4 E*Requested here: - E*{1}:2 + E*{}:2 *1 failed* """.format(conffile.basename, testfile.basename)) @@ -3211,9 +3211,9 @@ class TestParameterizedSubRequest(object): E*Failed: The requested fixture has no parameter defined for the current test. E* E*Requested fixture 'fix_with_param' defined in: - E*{0}:5 + E*{}:5 E*Requested here: - E*{1}:5 + E*{}:5 *1 failed* """.format(fixfile.strpath, testfile.basename)) diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index db6dae318..1942005bb 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -306,7 +306,7 @@ class TestMetafunc(object): pytest.param(re.compile('foo'), re.compile('bar')), pytest.param(str, int), pytest.param(list("six"), [66, 66]), - pytest.param(set([7]), set("seven")), + pytest.param({7}, set("seven")), pytest.param(tuple("eight"), (8, -8, 8)), pytest.param(b'\xc3\xb4', b"name"), pytest.param(b'\xc3\xb4', totext("other")), @@ -1214,14 +1214,14 @@ class TestMetafuncFunctional(object): testdir.makepyfile(""" import pytest - @pytest.mark.{0}("x", range(2)) + @pytest.mark.{}("x", range(2)) def test_foo(x): pass """.format(attr)) reprec = testdir.inline_run('--collectonly') failures = reprec.getfailures() assert len(failures) == 1 - expectederror = "MarkerError: test_foo has '{0}', spelling should be 'parametrize'".format(attr) + expectederror = "MarkerError: test_foo has '{}', spelling should be 'parametrize'".format(attr) assert expectederror in failures[0].longrepr.reprcrash.message diff --git a/testing/python/raises.py b/testing/python/raises.py index 053426395..3904d9757 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -75,7 +75,7 @@ class TestRaises(object): try: pytest.raises(ValueError, int, '0') except pytest.raises.Exception as e: - assert e.msg == "DID NOT RAISE {0}".format(repr(ValueError)) + assert e.msg == "DID NOT RAISE {}".format(repr(ValueError)) else: assert False, "Expected pytest.raises.Exception" @@ -83,7 +83,7 @@ class TestRaises(object): with pytest.raises(ValueError): pass except pytest.raises.Exception as e: - assert e.msg == "DID NOT RAISE {0}".format(repr(ValueError)) + assert e.msg == "DID NOT RAISE {}".format(repr(ValueError)) else: assert False, "Expected pytest.raises.Exception" @@ -134,7 +134,7 @@ class TestRaises(object): int('asdf') msg = "with base 16" - expr = r"Pattern '{0}' not found in 'invalid literal for int\(\) with base 10: 'asdf''".format(msg) + expr = r"Pattern '{}' not found in 'invalid literal for int\(\) with base 10: 'asdf''".format(msg) with pytest.raises(AssertionError, match=expr): with pytest.raises(ValueError, match=msg): int('asdf', base=10) diff --git a/testing/test_assertion.py b/testing/test_assertion.py index 51229d3e1..f7b69ba2d 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -359,7 +359,7 @@ class TestAssert_reprcompare(object): + {0: 2} ? ^ """), - (set([0, 1]), set([0, 2]), """ + ({0, 1}, {0, 2}, """ Full diff: - set([0, 1]) ? ^ @@ -417,11 +417,11 @@ class TestAssert_reprcompare(object): assert lines[2] == "{'b': 1}" def test_set(self): - expl = callequal(set([0, 1]), set([0, 2])) + expl = callequal({0, 1}, {0, 2}) assert len(expl) > 1 def test_frozenzet(self): - expl = callequal(frozenset([0, 1]), set([0, 2])) + expl = callequal(frozenset([0, 1]), {0, 2}) assert len(expl) > 1 def test_Sequence(self): @@ -971,7 +971,7 @@ def test_set_with_unsortable_elements(): raise RuntimeError() def __repr__(self): - return 'repr({0})'.format(self.name) + return 'repr({})'.format(self.name) def __eq__(self, other): return self.name == other.name @@ -979,8 +979,8 @@ def test_set_with_unsortable_elements(): def __hash__(self): return hash(self.name) - left_set = set(UnsortableKey(str(i)) for i in range(1, 3)) - right_set = set(UnsortableKey(str(i)) for i in range(2, 4)) + left_set = {UnsortableKey(str(i)) for i in range(1, 3)} + right_set = {UnsortableKey(str(i)) for i in range(2, 4)} expl = callequal(left_set, right_set, verbose=True) # skip first line because it contains the "construction" of the set, which does not have a guaranteed order expl = expl[1:] diff --git a/testing/test_config.py b/testing/test_config.py index 39105f5d6..c7b6647b7 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -624,7 +624,7 @@ def test_load_initial_conftest_last_ordering(testdir): def test_get_plugin_specs_as_list(): from _pytest.config import _get_plugin_specs_as_list with pytest.raises(pytest.UsageError): - _get_plugin_specs_as_list(set(['foo'])) + _get_plugin_specs_as_list({'foo'}) with pytest.raises(pytest.UsageError): _get_plugin_specs_as_list(dict()) diff --git a/testing/test_doctest.py b/testing/test_doctest.py index 314398395..b830473a4 100644 --- a/testing/test_doctest.py +++ b/testing/test_doctest.py @@ -117,8 +117,8 @@ class TestDoctests(object): >>> 1 1 """) - expected = set(['xdoc.txt', 'test.foo', 'test_normal.txt']) - assert set(x.basename for x in testdir.tmpdir.listdir()) == expected + expected = {'xdoc.txt', 'test.foo', 'test_normal.txt'} + assert {x.basename for x in testdir.tmpdir.listdir()} == expected args = ["--doctest-glob=xdoc*.txt", "--doctest-glob=*.foo"] result = testdir.runpytest(*args) result.stdout.fnmatch_lines([ @@ -145,11 +145,11 @@ class TestDoctests(object): """ testdir.makeini(""" [pytest] - doctest_encoding={0} + doctest_encoding={} """.format(encoding)) doctest = u""" - >>> u"{0}" - {1} + >>> u"{}" + {} """.format(test_string, repr(test_string)) testdir._makefile(".txt", [doctest], {}, encoding=encoding) diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index a8f5b9fec..3c34299db 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -23,8 +23,8 @@ def assert_attr(node, **kwargs): if anode is not None: return anode.value - expected = dict((name, str(value)) for name, value in kwargs.items()) - on_node = dict((name, nodeval(node, name)) for name in expected) + expected = {name: str(value) for name, value in kwargs.items()} + on_node = {name: nodeval(node, name) for name in expected} assert on_node == expected @@ -1079,7 +1079,7 @@ def test_set_suite_name(testdir, suite_name): if suite_name: testdir.makeini(""" [pytest] - junit_suite_name={0} + junit_suite_name={} """.format(suite_name)) expected = suite_name else: diff --git a/testing/test_mark.py b/testing/test_mark.py index 764678ab4..f79baf0fc 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -744,11 +744,11 @@ class TestFunctional(object): to other modules. """ from _pytest.mark import MarkInfo - items = dict((x.name, x) for x in items) + items = {x.name: x for x in items} for name, expected_markers in expected.items(): markers = items[name].keywords._markers - marker_names = set([name for (name, v) in markers.items() - if isinstance(v, MarkInfo)]) + marker_names = {name for (name, v) in markers.items() + if isinstance(v, MarkInfo)} assert marker_names == set(expected_markers) @pytest.mark.issue1540 diff --git a/testing/test_parseopt.py b/testing/test_parseopt.py index 55983bbb1..298448a2b 100644 --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -90,7 +90,7 @@ class TestParser(object): group.addoption("--option1", "--option-1", action="store_true") with pytest.raises(ValueError) as err: group.addoption("--option1", "--option-one", action="store_true") - assert str(set(["--option1"])) in str(err.value) + assert str({"--option1"}) in str(err.value) def test_group_shortopt_lowercase(self, parser): group = parser.getgroup("hello") |