Patchwork D4178: tests: move chunks of test-parseindex2.py to use unittest properly

login
register
mail settings
Submitter phabricator
Date Aug. 9, 2018, 5:45 p.m.
Message ID <47e8d7bfe23fbe28193308a2aca23cf5@localhost.localdomain>
Download mbox | patch
Permalink /patch/33471/
State Not Applicable
Headers show

Comments

phabricator - Aug. 9, 2018, 5:45 p.m.
durin42 updated this revision to Diff 10121.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4178?vs=10110&id=10121

REVISION DETAIL
  https://phab.mercurial-scm.org/D4178

AFFECTED FILES
  tests/test-parseindex2.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-parseindex2.py b/tests/test-parseindex2.py
--- a/tests/test-parseindex2.py
+++ b/tests/test-parseindex2.py
@@ -176,12 +176,8 @@ 
 
     def testbadargs(self):
         # Check that parse_index2() raises TypeError on bad arguments.
-        try:
+        with self.assertRaises(TypeError):
             parse_index2(0, True)
-        except TypeError:
-            pass
-        else:
-            print("Expected to get TypeError.")
 
     def testparseindexfile(self):
         # Check parsers.parse_index2() on an index file against the
@@ -194,20 +190,17 @@ 
         py_res_2 = py_parseindex(data_non_inlined, False)
         c_res_2 = parse_index2(data_non_inlined, False)
 
-        if py_res_1 != c_res_1:
-            print("Parse index result (with inlined data) differs!")
-
-        if py_res_2 != c_res_2:
-            print("Parse index result (no inlined data) differs!")
+        self.assertEqual(py_res_1, c_res_1) # inline data
+        self.assertEqual(py_res_2, c_res_2) # no inline data
 
         ix = parsers.parse_index2(data_inlined, True)[0]
         for i, r in enumerate(ix):
             if r[7] == nullid:
                 i = -1
             try:
-                if ix[r[7]] != i:
-                    print('Reverse lookup inconsistent for %r'
-                        % r[7].encode('hex'))
+                self.assertEqual(
+                    ix[r[7]], i,
+                    'Reverse lookup inconsistent for %r' % r[7].encode('hex'))
             except TypeError:
                 # pure version doesn't support this
                 break