Skip to content

Commit 8e9ff03

Browse files
committed
Upgrade Python syntax with pyupgrade --py3-plus
1 parent 8ac35fb commit 8e9ff03

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

src/pytest_mock/plugin.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import unicode_literals
2-
31
import functools
42
import inspect
53
import sys
@@ -39,7 +37,7 @@ def _get_mock_module(config):
3937
return _get_mock_module._module
4038

4139

42-
class MockFixture(object):
40+
class MockFixture:
4341
"""
4442
Fixture that provides the same interface to functions in the mock module,
4543
ensuring that they are uninstalled at the end of each test.
@@ -136,7 +134,7 @@ def stub(self, name=None):
136134
"""
137135
return self.mock_module.MagicMock(spec=lambda *args, **kwargs: None, name=name)
138136

139-
class _Patcher(object):
137+
class _Patcher:
140138
"""
141139
Object to provide the same interface as mock.patch, mock.patch.object,
142140
etc. We need this indirection to keep the same API of the mock package.

tests/test_pytest_mock.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def needs_assert_rewrite(pytestconfig):
3232
)
3333

3434

35-
class UnixFS(object):
35+
class UnixFS:
3636
"""
3737
Wrapper to os functions to simulate a Unix file system, used for testing
3838
the mock fixture.
@@ -205,7 +205,7 @@ def test_repr_with_no_name(self, mocker):
205205
def test_repr_with_name(self, mocker):
206206
test_name = "funny walk"
207207
stub = mocker.stub(name=test_name)
208-
assert "name={0!r}".format(test_name) in repr(stub)
208+
assert "name={!r}".format(test_name) in repr(stub)
209209

210210
def __test_failure_message(self, mocker, **kwargs):
211211
expected_name = kwargs.get("name") or "mock"
@@ -228,7 +228,7 @@ def test_failure_message_with_name(self, mocker, name):
228228

229229

230230
def test_instance_method_spy(mocker):
231-
class Foo(object):
231+
class Foo:
232232
def bar(self, arg):
233233
return arg * 2
234234

@@ -246,7 +246,7 @@ def bar(self, arg):
246246
def test_instance_method_spy_exception(mocker):
247247
excepted_message = "foo"
248248

249-
class Foo(object):
249+
class Foo:
250250
def bar(self, arg):
251251
raise Exception(excepted_message)
252252

@@ -264,7 +264,7 @@ def bar(self, arg):
264264

265265
@skip_pypy
266266
def test_instance_method_by_class_spy(mocker):
267-
class Foo(object):
267+
class Foo:
268268
def bar(self, arg):
269269
return arg * 2
270270

@@ -279,7 +279,7 @@ def bar(self, arg):
279279

280280
@skip_pypy
281281
def test_instance_method_by_subclass_spy(mocker):
282-
class Base(object):
282+
class Base:
283283
def bar(self, arg):
284284
return arg * 2
285285

@@ -298,7 +298,7 @@ class Foo(Base):
298298

299299
@skip_pypy
300300
def test_class_method_spy(mocker):
301-
class Foo(object):
301+
class Foo:
302302
@classmethod
303303
def bar(cls, arg):
304304
return arg * 2
@@ -314,7 +314,7 @@ def bar(cls, arg):
314314
@skip_pypy
315315
@pytest.mark.xfail(sys.version_info[0] == 2, reason="does not work on Python 2")
316316
def test_class_method_subclass_spy(mocker):
317-
class Base(object):
317+
class Base:
318318
@classmethod
319319
def bar(self, arg):
320320
return arg * 2
@@ -335,7 +335,7 @@ def test_class_method_with_metaclass_spy(mocker):
335335
class MetaFoo(type):
336336
pass
337337

338-
class Foo(object):
338+
class Foo:
339339

340340
__metaclass__ = MetaFoo
341341

@@ -353,7 +353,7 @@ def bar(cls, arg):
353353

354354
@skip_pypy
355355
def test_static_method_spy(mocker):
356-
class Foo(object):
356+
class Foo:
357357
@staticmethod
358358
def bar(arg):
359359
return arg * 2
@@ -369,7 +369,7 @@ def bar(arg):
369369
@skip_pypy
370370
@pytest.mark.xfail(sys.version_info[0] == 2, reason="does not work on Python 2")
371371
def test_static_method_subclass_spy(mocker):
372-
class Base(object):
372+
class Base:
373373
@staticmethod
374374
def bar(arg):
375375
return arg * 2
@@ -492,8 +492,8 @@ def test_assert_called_wrapper(mocker):
492492
def test_assert_called_args_with_introspection(mocker):
493493
stub = mocker.stub()
494494

495-
complex_args = ("a", 1, set(["test"]))
496-
wrong_args = ("b", 2, set(["jest"]))
495+
complex_args = ("a", 1, {"test"})
496+
wrong_args = ("b", 2, {"jest"})
497497

498498
stub(*complex_args)
499499
stub.assert_called_with(*complex_args)
@@ -714,7 +714,7 @@ def test_assert_called_with_unicode_arguments(mocker):
714714
stub(b"l\xc3\xb6k".decode("UTF-8"))
715715

716716
with pytest.raises(AssertionError):
717-
stub.assert_called_with(u"lak")
717+
stub.assert_called_with("lak")
718718

719719

720720
def test_plain_stopall(testdir):
@@ -739,7 +739,7 @@ def test_get_random_number(mocker):
739739

740740

741741
def test_abort_patch_object_context_manager(mocker):
742-
class A(object):
742+
class A:
743743
def doIt(self):
744744
return False
745745

0 commit comments

Comments
 (0)