diff options
| author | Kumar Akshay <k.akshay9721@gmail.com> | 2019-03-22 13:40:40 +0530 |
|---|---|---|
| committer | Chris Withers <chris@withers.org> | 2019-03-22 08:10:40 +0000 |
| commit | b0df45e55dc8304bac0e3cad0225472b84190964 (patch) | |
| tree | 14726255b39569c2d0b748bc7393ce2ce2423128 /Lib/unittest/test/testmock/testmock.py | |
| parent | 40b6907b377cfc8c4743007894364ac8c5a1c113 (diff) | |
| download | cpython-git-b0df45e55dc8304bac0e3cad0225472b84190964.tar.gz | |
bpo-21269: Provide args and kwargs attributes on mock call objects GH11807
Diffstat (limited to 'Lib/unittest/test/testmock/testmock.py')
| -rw-r--r-- | Lib/unittest/test/testmock/testmock.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py index 2ad90ea81e..66a5720d14 100644 --- a/Lib/unittest/test/testmock/testmock.py +++ b/Lib/unittest/test/testmock/testmock.py @@ -267,6 +267,10 @@ class MockTest(unittest.TestCase): self.assertEqual(mock.call_count, 1, "call_count incoreect") self.assertEqual(mock.call_args, ((sentinel.Arg,), {}), "call_args not set") + self.assertEqual(mock.call_args.args, (sentinel.Arg,), + "call_args not set") + self.assertEqual(mock.call_args.kwargs, {}, + "call_args not set") self.assertEqual(mock.call_args_list, [((sentinel.Arg,), {})], "call_args_list not initialised correctly") @@ -300,6 +304,8 @@ class MockTest(unittest.TestCase): ]) self.assertEqual(mock.call_args, ((sentinel.Arg,), {"kw": sentinel.Kwarg})) + self.assertEqual(mock.call_args.args, (sentinel.Arg,)) + self.assertEqual(mock.call_args.kwargs, {"kw": sentinel.Kwarg}) # Comparing call_args to a long sequence should not raise # an exception. See issue 24857. @@ -1157,9 +1163,8 @@ class MockTest(unittest.TestCase): mock(2, b=4) self.assertEqual(len(mock.call_args), 2) - args, kwargs = mock.call_args - self.assertEqual(args, (2,)) - self.assertEqual(kwargs, dict(b=4)) + self.assertEqual(mock.call_args.args, (2,)) + self.assertEqual(mock.call_args.kwargs, dict(b=4)) expected_list = [((1,), dict(a=3)), ((2,), dict(b=4))] for expected, call_args in zip(expected_list, mock.call_args_list): |
