Skip to content

Commit 4b50bc1

Browse files
authored
Merge pull request #80 from indrat/add-mock-backport
Add backport for mock
2 parents ad65edf + 306b205 commit 4b50bc1

File tree

6 files changed

+17
-4
lines changed

6 files changed

+17
-4
lines changed

tests/backports.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def test_modules(self):
1414
"faulthandler",
1515
"importlib",
1616
"ipaddress",
17+
"mock",
1718
"statistics",
1819
"typing",
1920
), Backports.modules())
@@ -32,5 +33,6 @@ def test_str(self):
3233
faulthandler - https://pypi.org/project/faulthandler/
3334
importlib - https://pypi.org/project/importlib/
3435
ipaddress - https://pypi.org/project/ipaddress/
36+
mock - https://pypi.org/project/mock/
3537
statistics - https://pypi.org/project/statistics/
3638
typing - https://pypi.org/project/typing/""", Backports.str(3))

tests/class.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ def test_TextTestResult_of_unittest(self):
102102

103103
def test_AsyncMock_of_unittest_mock(self):
104104
self.assertOnlyIn((3, 8), self.detect("from unittest.mock import AsyncMock"))
105+
self.assertTrue(self.config.add_backport("mock"))
106+
self.assertOnlyIn(((3, 6)), self.detect("from unittest.mock import AsyncMock"))
105107

106108
def test_DefragResult_of_urllib_parse(self):
107109
self.assertOnlyIn((3, 2), self.detect("from urllib.parse import DefragResult"))

tests/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3152,9 +3152,13 @@ def test_TYPE_IGNORE_of_token(self):
31523152

31533153
def test_args_of_unittest_mock_Mock_call_args(self):
31543154
self.assertOnlyIn((3, 8), self.detect("from unittest.mock.Mock.call_args import args"))
3155+
self.assertTrue(self.config.add_backport("mock"))
3156+
self.assertOnlyIn((3, 6), self.detect("from unittest.mock.Mock.call_args import args"))
31553157

31563158
def test_kwargs_of_unittest_mock_Mock_call_args(self):
31573159
self.assertOnlyIn((3, 8), self.detect("from unittest.mock.Mock.call_args import kwargs"))
3160+
self.assertTrue(self.config.add_backport("mock"))
3161+
self.assertOnlyIn((3, 6), self.detect("from unittest.mock.Mock.call_args import kwargs"))
31583162

31593163
def test_status_of_urllib_response_addinfourl(self):
31603164
self.assertOnlyIn((3, 9), self.detect("from urllib.response.addinfourl import status"))

tests/function.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,6 +1815,8 @@ def test_import_module_from_test_support(self):
18151815

18161816
def test_seal_from_unittest_mock(self):
18171817
self.assertOnlyIn((3, 7), self.detect("import unittest.mock\nunittest.mock.seal()"))
1818+
self.assertTrue(self.config.add_backport("mock"))
1819+
self.assertOnlyIn(((3, 6)), self.detect("import unittest.mock\nunittest.mock.seal()"))
18181820

18191821
def test_quoteattr_from_xml_sax_saxutils(self):
18201822
self.assertOnlyIn(((2, 2), (3, 0)), self.detect(

vermin/backports.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
("faulthandler", ["https://pypi.org/project/faulthandler/"]),
1111
("importlib", ["https://pypi.org/project/importlib/"]),
1212
("ipaddress", ["https://pypi.org/project/ipaddress/"]),
13+
("mock", ["https://pypi.org/project/mock/"]),
1314
("statistics", ["https://pypi.org/project/statistics/"]),
1415
("typing", ["https://pypi.org/project/typing/"]),
1516
)

vermin/rules.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def MOD_MEM_REQS(config):
348348
"typing.TypedDict": (None, (3, 8)) if not bp("typing", config) else ((2, 7), (3, 8)),
349349
"unittest.IsolatedAsyncioTestCase": (None, (3, 8)),
350350
"unittest.TextTestResult": ((2, 7), (3, 2)),
351-
"unittest.mock.AsyncMock": (None, (3, 8)),
351+
"unittest.mock.AsyncMock": (None, (3, 8)) if not bp("mock", config) else (None, (3, 6)),
352352
"urllib.parse.DefragResult": (None, (3, 2)),
353353
"urllib.parse.DefragResultBytes": (None, (3, 2)),
354354
"urllib.parse.ParseResultBytes": (None, (3, 2)),
@@ -1597,7 +1597,7 @@ def MOD_MEM_REQS(config):
15971597
"unittest.mock.Mock.assert_called": (None, (3, 6)),
15981598
"unittest.mock.Mock.assert_called_once": (None, (3, 6)),
15991599
"unittest.mock.Mock.assert_not_called": (None, (3, 5)),
1600-
"unittest.mock.seal": (None, (3, 7)),
1600+
"unittest.mock.seal": (None, (3, 7)) if not bp("mock", config) else (None, (3, 6)),
16011601
"unittest.registerResult": ((2, 7), (3, 2)),
16021602
"unittest.removeHandler": ((2, 7), (3, 2)),
16031603
"unittest.removeResult": ((2, 7), (3, 2)),
@@ -2478,8 +2478,10 @@ def MOD_MEM_REQS(config):
24782478
"unittest.TestResult.failfast": ((2, 7), (3, 2)),
24792479
"unittest.TestResult.skipped": ((2, 7), (3, 1)),
24802480
"unittest.TestResult.tb_locals": (None, (3, 5)),
2481-
"unittest.mock.Mock.call_args.args": (None, (3, 8)),
2482-
"unittest.mock.Mock.call_args.kwargs": (None, (3, 8)),
2481+
"unittest.mock.Mock.call_args.args": (None, (3, 8))
2482+
if not bp("mock", config) else (None, (3, 6)),
2483+
"unittest.mock.Mock.call_args.kwargs": (None, (3, 8))
2484+
if not bp("mock", config) else (None, (3, 6)),
24832485
"urllib.error.HTTPError.headers": (None, (3, 4)),
24842486
"urllib.parse._UNSAFE_URL_BYTES_TO_REMOVE": (None, (3, 10)),
24852487
"urllib.request.Request.method": (None, (3, 3)),

0 commit comments

Comments
 (0)