From 75d0b899bbb56d6849e9d69d83a9426ed3f43f8b Mon Sep 17 00:00:00 2001 From: boris Date: Tue, 6 Aug 2019 13:33:21 -0700 Subject: [PATCH] ran pyupgrade-docs again --- doc/en/example/parametrize.rst | 10 +++++----- doc/en/example/pythoncollection.rst | 2 +- doc/en/example/special.rst | 6 +++--- doc/en/fixture.rst | 14 +++++++------- doc/en/funcarg_compare.rst | 2 +- doc/en/getting-started.rst | 2 +- doc/en/unittest.rst | 2 +- doc/en/usage.rst | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index ac9f81a38..b707aeac4 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -190,13 +190,13 @@ only have to work a bit to construct the correct arguments for pytest's idlist.append(scenario[0]) items = scenario[1].items() argnames = [x[0] for x in items] - argvalues.append(([x[1] for x in items])) + argvalues.append([x[1] for x in items]) metafunc.parametrize(argnames, argvalues, ids=idlist, scope="class") scenario1 = ('basic', {'attribute': 'value'}) scenario2 = ('advanced', {'attribute': 'value2'}) - class TestSampleWithScenarios(object): + class TestSampleWithScenarios: scenarios = [scenario1, scenario2] def test_demo1(self, attribute): @@ -277,9 +277,9 @@ creates a database object for the actual test invocations:: if 'db' in metafunc.fixturenames: metafunc.parametrize("db", ['d1', 'd2'], indirect=True) - class DB1(object): + class DB1: "one database object" - class DB2(object): + class DB2: "alternative database object" @pytest.fixture @@ -398,7 +398,7 @@ parametrizer`_ but in a lot less code:: metafunc.parametrize(argnames, [[funcargs[name] for name in argnames] for funcargs in funcarglist]) - class TestClass(object): + class TestClass: # a map specifying multiple argument sets for a test method params = { 'test_equals': [dict(a=1, b=2), dict(a=3, b=3), ], diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 86b7fe566..89619bca3 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -136,7 +136,7 @@ that match ``*_check``. For example, if we have:: .. code-block:: python # content of check_myapp.py - class CheckMyApp(object): + class CheckMyApp: def simple_check(self): pass def complex_check(self): diff --git a/doc/en/example/special.rst b/doc/en/example/special.rst index c8fc96786..bc65f4d48 100644 --- a/doc/en/example/special.rst +++ b/doc/en/example/special.rst @@ -16,7 +16,7 @@ calls it:: @pytest.fixture(scope="session", autouse=True) def callattr_ahead_of_alltests(request): print("callattr_ahead_of_alltests called") - seen = set([None]) + seen = {None} session = request.node for item in session.items: cls = item.getparent(pytest.Class) @@ -32,7 +32,7 @@ will be called ahead of running any tests:: # content of test_module.py - class TestHello(object): + class TestHello: @classmethod def callme(cls): print("callme called!") @@ -43,7 +43,7 @@ will be called ahead of running any tests:: def test_method2(self): print("test_method1 called") - class TestOther(object): + class TestOther: @classmethod def callme(cls): print("callme other called") diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index 9ba2552ba..8957c48bb 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -496,7 +496,7 @@ read an optional server URL from the test module which uses our fixture:: server = getattr(request.module, "smtpserver", "smtp.gmail.com") smtp_connection = smtplib.SMTP(server, 587, timeout=5) yield smtp_connection - print("finalizing %s (%s)" % (smtp_connection, server)) + print("finalizing {} ({})".format(smtp_connection, server)) smtp_connection.close() We use the ``request.module`` attribute to optionally obtain an @@ -820,7 +820,7 @@ and instantiate an object ``app`` where we stick the already defined import pytest - class App(object): + class App: def __init__(self, smtp_connection): self.smtp_connection = smtp_connection @@ -902,7 +902,7 @@ to show the setup/teardown flow:: def test_1(modarg): print(" RUN test1 with modarg %s" % modarg) def test_2(otherarg, modarg): - print(" RUN test2 with otherarg %s and modarg %s" % (otherarg, modarg)) + print(" RUN test2 with otherarg {} and modarg {}".format(otherarg, modarg)) Let's run the tests in verbose mode and with looking at the print-output: @@ -1001,7 +1001,7 @@ and declare its use in a test module via a ``usefixtures`` marker:: import pytest @pytest.mark.usefixtures("cleandir") - class TestDirectoryInit(object): + class TestDirectoryInit: def test_cwd_starts_empty(self): assert os.listdir(os.getcwd()) == [] with open("myfile", "w") as f: @@ -1086,7 +1086,7 @@ self-contained implementation of this idea:: import pytest - class DB(object): + class DB: def __init__(self): self.intransaction = [] def begin(self, name): @@ -1098,7 +1098,7 @@ self-contained implementation of this idea:: def db(): return DB() - class TestClass(object): + class TestClass: @pytest.fixture(autouse=True) def transact(self, request, db): db.begin(request.function.__name__) @@ -1162,7 +1162,7 @@ and then e.g. have a TestClass using it by declaring the need:: .. code-block:: python @pytest.mark.usefixtures("transact") - class TestClass(object): + class TestClass: def test_method1(self): ... diff --git a/doc/en/funcarg_compare.rst b/doc/en/funcarg_compare.rst index c9939d70f..131ceb1ae 100644 --- a/doc/en/funcarg_compare.rst +++ b/doc/en/funcarg_compare.rst @@ -26,7 +26,7 @@ a per-session Database object:: .. code-block:: python # content of conftest.py - class Database(object): + class Database: def __init__(self): print("database instance created") def destroy(self): diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 124c1e686..b2d597e1e 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -114,7 +114,7 @@ Once you develop multiple tests, you may want to group them into a class. pytest .. code-block:: python # content of test_class.py - class TestClass(object): + class TestClass: def test_one(self): x = "this" assert 'h' in x diff --git a/doc/en/unittest.rst b/doc/en/unittest.rst index 9b3d9bd60..e8063c173 100644 --- a/doc/en/unittest.rst +++ b/doc/en/unittest.rst @@ -93,7 +93,7 @@ it from a unittest-style test:: @pytest.fixture(scope="class") def db_class(request): - class DummyDB(object): + class DummyDB: pass # set a class attribute on the invoking test context request.cls.db = DummyDB() diff --git a/doc/en/usage.rst b/doc/en/usage.rst index f29e018a1..ef6d2712e 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -774,7 +774,7 @@ You can specify additional plugins to ``pytest.main``:: # content of myinvoke.py import pytest - class MyPlugin(object): + class MyPlugin: def pytest_sessionfinish(self): print("*** test run reporting finishing")