ran pyupgrade-docs again

This commit is contained in:
boris 2019-08-06 13:33:21 -07:00
parent 7f90e74e02
commit 75d0b899bb
8 changed files with 20 additions and 20 deletions

View File

@ -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), ],

View File

@ -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):

View File

@ -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")

View File

@ -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):
...

View File

@ -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):

View File

@ -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

View File

@ -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()

View File

@ -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")