Skip to content

Commit cf7761f

Browse files
author
boris
committed
ran pyupgrade-docs
1 parent 68c486a commit cf7761f

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

doc/en/assert.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,14 @@ file which provides an alternative explanation for ``Foo`` objects:
238238
239239
def pytest_assertrepr_compare(op, left, right):
240240
if isinstance(left, Foo) and isinstance(right, Foo) and op == "==":
241-
return ["Comparing Foo instances:", " vals: %s != %s" % (left.val, right.val)]
241+
return ["Comparing Foo instances:", " vals: {} != {}".format(left.val, right.val)]
242242
243243
now, given this test module:
244244

245245
.. code-block:: python
246246
247247
# content of test_foocompare.py
248-
class Foo(object):
248+
class Foo:
249249
def __init__(self, val):
250250
self.val = val
251251

doc/en/example/attic.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ example: specifying and selecting acceptance tests
1818
return AcceptFixture(request)
1919

2020

21-
class AcceptFixture(object):
21+
class AcceptFixture:
2222
def __init__(self, request):
2323
if not request.config.getoption("acceptance"):
2424
pytest.skip("specify -A to run acceptance tests")
@@ -65,7 +65,7 @@ extend the `accept example`_ by putting this in our test module:
6565
return arg
6666

6767

68-
class TestSpecialAcceptance(object):
68+
class TestSpecialAcceptance:
6969
def test_sometest(self, accept):
7070
assert accept.tmpdir.join("special").check()
7171

doc/en/example/markers.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ You can "mark" a test function with custom metadata like this:
3333
pass
3434
3535
36-
class TestClass(object):
36+
class TestClass:
3737
def test_method(self):
3838
pass
3939
@@ -278,7 +278,7 @@ its test methods:
278278
279279
280280
@pytest.mark.webtest
281-
class TestClass(object):
281+
class TestClass:
282282
def test_startup(self):
283283
pass
284284
@@ -295,7 +295,7 @@ Due to legacy reasons, it is possible to set the ``pytestmark`` attribute on a T
295295
import pytest
296296
297297
298-
class TestClass(object):
298+
class TestClass:
299299
pytestmark = pytest.mark.webtest
300300
301301
or if you need to use multiple markers you can use a list:
@@ -305,7 +305,7 @@ or if you need to use multiple markers you can use a list:
305305
import pytest
306306
307307
308-
class TestClass(object):
308+
class TestClass:
309309
pytestmark = [pytest.mark.webtest, pytest.mark.slowtest]
310310
311311
You can also set a module level marker::
@@ -523,7 +523,7 @@ code you can read over all such settings. Example:
523523
524524
525525
@pytest.mark.glob("class", x=2)
526-
class TestClass(object):
526+
class TestClass:
527527
@pytest.mark.glob("function", x=3)
528528
def test_something(self):
529529
pass
@@ -539,7 +539,7 @@ test function. From a conftest file we can read it like this:
539539
540540
def pytest_runtest_setup(item):
541541
for mark in item.iter_markers(name="glob"):
542-
print("glob args=%s kwargs=%s" % (mark.args, mark.kwargs))
542+
print("glob args={} kwargs={}".format(mark.args, mark.kwargs))
543543
sys.stdout.flush()
544544
545545
Let's run this without capturing output and see what we get:

doc/en/example/simple.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ Example:
238238
def checkconfig(x):
239239
__tracebackhide__ = True
240240
if not hasattr(x, "config"):
241-
pytest.fail("not configured: %s" % (x,))
241+
pytest.fail("not configured: {}".format(x))
242242
243243
244244
def test_something():
@@ -280,7 +280,7 @@ this to make sure unexpected exception types aren't hidden:
280280
def checkconfig(x):
281281
__tracebackhide__ = operator.methodcaller("errisinstance", ConfigException)
282282
if not hasattr(x, "config"):
283-
raise ConfigException("not configured: %s" % (x,))
283+
raise ConfigException("not configured: {}".format(x))
284284
285285
286286
def test_something():
@@ -491,7 +491,7 @@ tests in a class. Here is a test module example:
491491
492492
493493
@pytest.mark.incremental
494-
class TestUserHandling(object):
494+
class TestUserHandling:
495495
def test_login(self):
496496
pass
497497
@@ -556,7 +556,7 @@ Here is an example for making a ``db`` fixture available in a directory:
556556
import pytest
557557
558558
559-
class DB(object):
559+
class DB:
560560
pass
561561
562562

doc/en/monkeypatch.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ to do this using the ``setenv`` and ``delenv`` method. Our example code to test:
272272
username = os.getenv("USER")
273273
274274
if username is None:
275-
raise EnvironmentError("USER environment is not set.")
275+
raise OSError("USER environment is not set.")
276276
277277
return username.lower()
278278
@@ -296,7 +296,7 @@ both paths can be safely tested without impacting the running environment:
296296
"""Remove the USER env var and assert EnvironmentError is raised."""
297297
monkeypatch.delenv("USER", raising=False)
298298
299-
with pytest.raises(EnvironmentError):
299+
with pytest.raises(OSError):
300300
_ = get_os_user_lower()
301301
302302
This behavior can be moved into ``fixture`` structures and shared across tests:
@@ -323,7 +323,7 @@ This behavior can be moved into ``fixture`` structures and shared across tests:
323323
324324
325325
def test_raise_exception(mock_env_missing):
326-
with pytest.raises(EnvironmentError):
326+
with pytest.raises(OSError):
327327
_ = get_os_user_lower()
328328
329329

doc/en/skipping.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ You can use the ``skipif`` marker (as any other marker) on classes:
145145
.. code-block:: python
146146
147147
@pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
148-
class TestPosixCalls(object):
148+
class TestPosixCalls:
149149
def test_function(self):
150150
"will not be setup or run under 'win32' platform"
151151

doc/en/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ to all tests.
652652
record_testsuite_property("STORAGE_TYPE", "CEPH")
653653
654654
655-
class TestMe(object):
655+
class TestMe:
656656
def test_foo(self):
657657
assert True
658658

doc/en/writing_plugins.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ declaring the hook functions directly in your plugin module, for example:
693693
# contents of myplugin.py
694694
695695
696-
class DeferPlugin(object):
696+
class DeferPlugin:
697697
"""Simple plugin to defer pytest-xdist hook functions."""
698698
699699
def pytest_testnodedown(self, node, error):

0 commit comments

Comments
 (0)