diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-11-14 21:50:51 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-11-14 21:50:51 (GMT) |
commit | 1eadd6a120d7f475cc4d2567087d27e7a196c6ca (patch) | |
tree | 6ff2208d0445d3c102345592589b56cba2ba4d4e /Lib/lib2to3/tests | |
parent | e048addedc4c54f3904069f154b3632da65d820b (diff) | |
parent | 8bdc130121550fa99d7e76c84a06deda21000cd4 (diff) | |
download | cpython-1eadd6a120d7f475cc4d2567087d27e7a196c6ca.zip cpython-1eadd6a120d7f475cc4d2567087d27e7a196c6ca.tar.gz cpython-1eadd6a120d7f475cc4d2567087d27e7a196c6ca.tar.bz2 |
Issue #19592: Use specific asserts in lib2to3 tests.
Diffstat (limited to 'Lib/lib2to3/tests')
-rw-r--r-- | Lib/lib2to3/tests/test_fixers.py | 2 | ||||
-rw-r--r-- | Lib/lib2to3/tests/test_main.py | 6 | ||||
-rw-r--r-- | Lib/lib2to3/tests/test_parser.py | 4 | ||||
-rw-r--r-- | Lib/lib2to3/tests/test_pytree.py | 16 | ||||
-rw-r--r-- | Lib/lib2to3/tests/test_refactor.py | 6 |
5 files changed, 17 insertions, 17 deletions
diff --git a/Lib/lib2to3/tests/test_fixers.py b/Lib/lib2to3/tests/test_fixers.py index 5b16bc3..bac6872 100644 --- a/Lib/lib2to3/tests/test_fixers.py +++ b/Lib/lib2to3/tests/test_fixers.py @@ -41,7 +41,7 @@ class FixerTestCase(support.TestCase): def warns(self, before, after, message, unchanged=False): tree = self._check(before, after) - self.assertTrue(message in "".join(self.fixer_log)) + self.assertIn(message, "".join(self.fixer_log)) if not unchanged: self.assertTrue(tree.was_changed) diff --git a/Lib/lib2to3/tests/test_main.py b/Lib/lib2to3/tests/test_main.py index a498c5a..a33c45c 100644 --- a/Lib/lib2to3/tests/test_main.py +++ b/Lib/lib2to3/tests/test_main.py @@ -49,9 +49,9 @@ class TestMain(unittest.TestCase): ret = self.run_2to3_capture(["-"], input_stream, out_enc, err) self.assertEqual(ret, 0) output = out.getvalue().decode("ascii") - self.assertTrue("-print 'nothing'" in output) - self.assertTrue("WARNING: couldn't encode <stdin>'s diff for " - "your terminal" in err.getvalue()) + self.assertIn("-print 'nothing'", output) + self.assertIn("WARNING: couldn't encode <stdin>'s diff for " + "your terminal", err.getvalue()) def setup_test_source_trees(self): """Setup a test source tree and output destination tree.""" diff --git a/Lib/lib2to3/tests/test_parser.py b/Lib/lib2to3/tests/test_parser.py index 09b439a..a383a14 100644 --- a/Lib/lib2to3/tests/test_parser.py +++ b/Lib/lib2to3/tests/test_parser.py @@ -168,8 +168,8 @@ class TestParserIdempotency(support.TestCase): for filepath in support.all_project_files(): with open(filepath, "rb") as fp: encoding = tokenize.detect_encoding(fp.readline)[0] - self.assertTrue(encoding is not None, - "can't detect encoding for %s" % filepath) + self.assertIsNotNone(encoding, + "can't detect encoding for %s" % filepath) with open(filepath, "r", encoding=encoding) as fp: source = fp.read() try: diff --git a/Lib/lib2to3/tests/test_pytree.py b/Lib/lib2to3/tests/test_pytree.py index a2ab1f3..4d585a8 100644 --- a/Lib/lib2to3/tests/test_pytree.py +++ b/Lib/lib2to3/tests/test_pytree.py @@ -143,12 +143,12 @@ class TestNodes(support.TestCase): l3 = pytree.Leaf(100, "bar") n1 = pytree.Node(1000, [l1, l2, l3]) self.assertEqual(n1.children, [l1, l2, l3]) - self.assertTrue(isinstance(n1.children, list)) + self.assertIsInstance(n1.children, list) self.assertFalse(n1.was_changed) l2new = pytree.Leaf(100, "-") l2.replace(l2new) self.assertEqual(n1.children, [l1, l2new, l3]) - self.assertTrue(isinstance(n1.children, list)) + self.assertIsInstance(n1.children, list) self.assertTrue(n1.was_changed) def test_replace_with_list(self): @@ -159,7 +159,7 @@ class TestNodes(support.TestCase): l2.replace([pytree.Leaf(100, "*"), pytree.Leaf(100, "*")]) self.assertEqual(str(n1), "foo**bar") - self.assertTrue(isinstance(n1.children, list)) + self.assertIsInstance(n1.children, list) def test_leaves(self): l1 = pytree.Leaf(100, "foo") @@ -330,7 +330,7 @@ class TestNodes(support.TestCase): n2 = pytree.Node(1000, []) p1 = pytree.Node(1000, [n1, n2]) - self.assertTrue(n1.next_sibling is n2) + self.assertIs(n1.next_sibling, n2) self.assertEqual(n2.next_sibling, None) self.assertEqual(p1.next_sibling, None) @@ -339,7 +339,7 @@ class TestNodes(support.TestCase): l2 = pytree.Leaf(100, "b") p1 = pytree.Node(1000, [l1, l2]) - self.assertTrue(l1.next_sibling is l2) + self.assertIs(l1.next_sibling, l2) self.assertEqual(l2.next_sibling, None) self.assertEqual(p1.next_sibling, None) @@ -348,7 +348,7 @@ class TestNodes(support.TestCase): n2 = pytree.Node(1000, []) p1 = pytree.Node(1000, [n1, n2]) - self.assertTrue(n2.prev_sibling is n1) + self.assertIs(n2.prev_sibling, n1) self.assertEqual(n1.prev_sibling, None) self.assertEqual(p1.prev_sibling, None) @@ -357,7 +357,7 @@ class TestNodes(support.TestCase): l2 = pytree.Leaf(100, "b") p1 = pytree.Node(1000, [l1, l2]) - self.assertTrue(l2.prev_sibling is l1) + self.assertIs(l2.prev_sibling, l1) self.assertEqual(l1.prev_sibling, None) self.assertEqual(p1.prev_sibling, None) @@ -430,7 +430,7 @@ class TestPatterns(support.TestCase): r = {} self.assertTrue(pw.match_seq([l1, l3], r)) self.assertEqual(r, {"pl": l3, "pw": [l1, l3]}) - self.assertTrue(r["pl"] is l3) + self.assertIs(r["pl"], l3) r = {} def test_generate_matches(self): diff --git a/Lib/lib2to3/tests/test_refactor.py b/Lib/lib2to3/tests/test_refactor.py index 5ecd9b1..f30c1e8 100644 --- a/Lib/lib2to3/tests/test_refactor.py +++ b/Lib/lib2to3/tests/test_refactor.py @@ -49,9 +49,9 @@ class TestRefactoringTool(unittest.TestCase): def test_print_function_option(self): rt = self.rt({"print_function" : True}) - self.assertTrue(rt.grammar is pygram.python_grammar_no_print_statement) - self.assertTrue(rt.driver.grammar is - pygram.python_grammar_no_print_statement) + self.assertIs(rt.grammar, pygram.python_grammar_no_print_statement) + self.assertIs(rt.driver.grammar, + pygram.python_grammar_no_print_statement) def test_write_unchanged_files_option(self): rt = self.rt() |