summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test/testmock
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-11-16 22:12:21 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-11-16 22:12:21 (GMT)
commit5665bc5980cd20252fe1d27807759cecee8594d0 (patch)
tree04c09b0879e10aa82e7023d916965206669e8475 /Lib/unittest/test/testmock
parent7c5e24f948e6ce33e21b09833f8fe3a8eb1530ac (diff)
downloadcpython-5665bc5980cd20252fe1d27807759cecee8594d0.zip
cpython-5665bc5980cd20252fe1d27807759cecee8594d0.tar.gz
cpython-5665bc5980cd20252fe1d27807759cecee8594d0.tar.bz2
Issue #19594: Use specific asserts in unittest tests.
Diffstat (limited to 'Lib/unittest/test/testmock')
-rw-r--r--Lib/unittest/test/testmock/testhelpers.py18
-rw-r--r--Lib/unittest/test/testmock/testmagicmethods.py8
-rw-r--r--Lib/unittest/test/testmock/testmock.py10
-rw-r--r--Lib/unittest/test/testmock/testsentinel.py2
4 files changed, 19 insertions, 19 deletions
diff --git a/Lib/unittest/test/testmock/testhelpers.py b/Lib/unittest/test/testmock/testhelpers.py
index 8bfb293..a362a2f 100644
--- a/Lib/unittest/test/testmock/testhelpers.py
+++ b/Lib/unittest/test/testmock/testhelpers.py
@@ -177,7 +177,7 @@ class CallTest(unittest.TestCase):
args = _Call(((1, 2, 3), {}))
self.assertEqual(args, call(1, 2, 3))
self.assertEqual(call(1, 2, 3), args)
- self.assertTrue(call(1, 2, 3) in [args])
+ self.assertIn(call(1, 2, 3), [args])
def test_call_ne(self):
@@ -793,7 +793,7 @@ class SpecSignatureTest(unittest.TestCase):
mock_property = foo.foo
# no spec on properties
- self.assertTrue(isinstance(mock_property, MagicMock))
+ self.assertIsInstance(mock_property, MagicMock)
mock_property(1, 2, 3)
mock_property.abc(4, 5, 6)
mock_property.assert_called_once_with(1, 2, 3)
@@ -826,19 +826,19 @@ class TestCallList(unittest.TestCase):
mock(b=6)
for kall in call(1, 2), call(a=3), call(3, 4), call(b=6):
- self.assertTrue(kall in mock.call_args_list)
+ self.assertIn(kall, mock.call_args_list)
calls = [call(a=3), call(3, 4)]
- self.assertTrue(calls in mock.call_args_list)
+ self.assertIn(calls, mock.call_args_list)
calls = [call(1, 2), call(a=3)]
- self.assertTrue(calls in mock.call_args_list)
+ self.assertIn(calls, mock.call_args_list)
calls = [call(3, 4), call(b=6)]
- self.assertTrue(calls in mock.call_args_list)
+ self.assertIn(calls, mock.call_args_list)
calls = [call(3, 4)]
- self.assertTrue(calls in mock.call_args_list)
+ self.assertIn(calls, mock.call_args_list)
- self.assertFalse(call('fish') in mock.call_args_list)
- self.assertFalse([call('fish')] in mock.call_args_list)
+ self.assertNotIn(call('fish'), mock.call_args_list)
+ self.assertNotIn([call('fish')], mock.call_args_list)
def test_call_list_str(self):
diff --git a/Lib/unittest/test/testmock/testmagicmethods.py b/Lib/unittest/test/testmock/testmagicmethods.py
index 2bcf088..5ff158d 100644
--- a/Lib/unittest/test/testmock/testmagicmethods.py
+++ b/Lib/unittest/test/testmock/testmagicmethods.py
@@ -37,12 +37,12 @@ class TestMockingMagicMethods(unittest.TestCase):
return self, 'fish'
mock.__getitem__ = f
- self.assertFalse(mock.__getitem__ is f)
+ self.assertIsNot(mock.__getitem__, f)
self.assertEqual(mock['foo'], (mock, 'fish'))
self.assertEqual(mock.__getitem__('foo'), (mock, 'fish'))
mock.__getitem__ = mock
- self.assertTrue(mock.__getitem__ is mock)
+ self.assertIs(mock.__getitem__, mock)
def test_magic_methods_isolated_between_mocks(self):
@@ -212,8 +212,8 @@ class TestMockingMagicMethods(unittest.TestCase):
self.assertEqual(len(mock), 6)
mock.__contains__ = lambda s, o: o == 3
- self.assertTrue(3 in mock)
- self.assertFalse(6 in mock)
+ self.assertIn(3, mock)
+ self.assertNotIn(6, mock)
mock.__iter__ = lambda s: iter('foobarbaz')
self.assertEqual(list(mock), list('foobarbaz'))
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py
index 3d0776c..cef5405 100644
--- a/Lib/unittest/test/testmock/testmock.py
+++ b/Lib/unittest/test/testmock/testmock.py
@@ -52,7 +52,7 @@ class MockTest(unittest.TestCase):
"method_calls not initialised correctly")
# Can't use hasattr for this test as it always returns True on a mock
- self.assertFalse('_items' in mock.__dict__,
+ self.assertNotIn('_items', mock.__dict__,
"default mock should not have '_items' attribute")
self.assertIsNone(mock._mock_parent,
@@ -493,19 +493,19 @@ class MockTest(unittest.TestCase):
pass
mock = Mock(spec=X)
- self.assertTrue(isinstance(mock, X))
+ self.assertIsInstance(mock, X)
mock = Mock(spec=X())
- self.assertTrue(isinstance(mock, X))
+ self.assertIsInstance(mock, X)
self.assertIs(mock.__class__, X)
self.assertEqual(Mock().__class__.__name__, 'Mock')
mock = Mock(spec_set=X)
- self.assertTrue(isinstance(mock, X))
+ self.assertIsInstance(mock, X)
mock = Mock(spec_set=X())
- self.assertTrue(isinstance(mock, X))
+ self.assertIsInstance(mock, X)
def test_setting_attribute_with_spec_set(self):
diff --git a/Lib/unittest/test/testmock/testsentinel.py b/Lib/unittest/test/testmock/testsentinel.py
index bfda68e..3fb5acb 100644
--- a/Lib/unittest/test/testmock/testsentinel.py
+++ b/Lib/unittest/test/testmock/testsentinel.py
@@ -17,7 +17,7 @@ class SentinelTest(unittest.TestCase):
def testDEFAULT(self):
- self.assertTrue(DEFAULT is sentinel.DEFAULT)
+ self.assertIs(DEFAULT, sentinel.DEFAULT)
def testBases(self):
# If this doesn't raise an AttributeError then help(mock) is broken