diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2018-06-26 13:49:06 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@users.noreply.github.com> | 2018-06-26 13:49:06 -0700 |
commit | e8afcc9ec212a35a285f4bd0357def92af5b81cb (patch) | |
tree | d753ab31a7981c352f4ddd4726dc1e26e1111673 /tests/test_c_ast.py | |
parent | 13224c18fa95f060b6df9c6e6fd09081775568f5 (diff) | |
download | pycparser-e8afcc9ec212a35a285f4bd0357def92af5b81cb.tar.gz |
Use more specific assertIsInstance in tests (#268)
When running tests with Python warnings enabled, warnings of the
following form appear:
DeprecationWarning: Please use assertTrue instead.
self.failUnless(isinstance(...))
Use assertIsInstance instead to fix these warnings.
Using a more specific assert also has the advantage of more informative
error reporting upon failure.
https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertTrue
> This method should also be avoided when more specific methods are
> available (e.g. assertEqual(a, b) instead of assertTrue(a == b)),
> because they provide a better error message in case of failure.
Diffstat (limited to 'tests/test_c_ast.py')
-rw-r--r-- | tests/test_c_ast.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/test_c_ast.py b/tests/test_c_ast.py index 8e95d55..6ea3ceb 100644 --- a/tests/test_c_ast.py +++ b/tests/test_c_ast.py @@ -16,11 +16,11 @@ class Test_c_ast(unittest.TestCase): left=c_ast.Constant(type='int', value='6'), right=c_ast.ID(name='joe')) - self.failUnless(isinstance(b1.left, c_ast.Constant)) + self.assertIsInstance(b1.left, c_ast.Constant) self.assertEqual(b1.left.type, 'int') self.assertEqual(b1.left.value, '6') - self.failUnless(isinstance(b1.right, c_ast.ID)) + self.assertIsInstance(b1.right, c_ast.ID) self.assertEqual(b1.right.name, 'joe') def test_weakref_works_on_nodes(self): |