diff tests/test_update.py @ 221:a2afbf236ca8

hglib tests: remove deprecated constructions This mostly removes usage of 'assertEquals' (replaced with 'assertEqual'), as well as opening files without closing them (fixed using a 'with' statement).
author Mathias De Mare <mathias.de_mare@nokia.com>
date Thu, 09 Mar 2023 14:00:02 +0100
parents 8341f2494b3f
children
line wrap: on
line diff
--- a/tests/test_update.py	Thu Mar 09 11:33:04 2023 +0100
+++ b/tests/test_update.py	Thu Mar 09 14:00:02 2023 +0100
@@ -12,19 +12,19 @@
 
     def test_basic(self):
         u, m, r, ur = self.client.update(self.rev0)
-        self.assertEquals(u, 1)
-        self.assertEquals(m, 0)
-        self.assertEquals(r, 0)
-        self.assertEquals(ur, 0)
+        self.assertEqual(u, 1)
+        self.assertEqual(m, 0)
+        self.assertEqual(r, 0)
+        self.assertEqual(ur, 0)
 
     def test_unresolved(self):
         self.client.update(self.rev0)
         self.append('a', 'b')
         u, m, r, ur = self.client.update()
-        self.assertEquals(u, 0)
-        self.assertEquals(m, 0)
-        self.assertEquals(r, 0)
-        self.assertEquals(ur, 1)
+        self.assertEqual(u, 0)
+        self.assertEqual(m, 0)
+        self.assertEqual(r, 0)
+        self.assertEqual(ur, 1)
         self.assertTrue((b('M'), b('a')) in self.client.status())
 
     def test_merge(self):
@@ -33,22 +33,23 @@
         self.append('a', 'b')
         self.client.commit(b('fourth'))
         self.client.update(rev2)
-        old = open('a').read()
+        with open('a') as f:
+            old = f.read()
         f = open('a', 'wb')
         f.write(b('a') + old.encode('latin-1'))
         f.close()
         u, m, r, ur = self.client.update()
-        self.assertEquals(u, 0)
-        self.assertEquals(m, 1)
-        self.assertEquals(r, 0)
-        self.assertEquals(ur, 0)
-        self.assertEquals(self.client.status(), [(b('M'), b('a'))])
+        self.assertEqual(u, 0)
+        self.assertEqual(m, 1)
+        self.assertEqual(r, 0)
+        self.assertEqual(ur, 0)
+        self.assertEqual(self.client.status(), [(b('M'), b('a'))])
 
     def test_tip(self):
         self.client.update(self.rev0)
         u, m, r, ur = self.client.update()
-        self.assertEquals(u, 1)
-        self.assertEquals(self.client.parents()[0].node, self.node1)
+        self.assertEqual(u, 1)
+        self.assertEqual(self.client.parents()[0].node, self.node1)
 
         self.client.update(self.rev0)
         self.append('a', 'b')
@@ -56,20 +57,22 @@
         self.client.update(self.rev0)
 
         self.client.update()
-        self.assertEquals(self.client.parents()[0].node, node2)
+        self.assertEqual(self.client.parents()[0].node, node2)
 
     def test_check_clean(self):
         self.assertRaises(ValueError, self.client.update, clean=True,
                           check=True)
 
     def test_clean(self):
-        old = open('a').read()
+        with open('a') as f:
+            old = f.read()
         self.append('a', 'b')
         self.assertRaises(error.CommandError, self.client.update, check=True)
 
         u, m, r, ur = self.client.update(clean=True)
-        self.assertEquals(u, 1)
-        self.assertEquals(old, open('a').read())
+        self.assertEqual(u, 1)
+        with open('a') as f:
+            self.assertEqual(old, f.read())
 
     def test_basic_plain(self):
         f = open('.hg/hgrc', 'a')
@@ -96,7 +99,7 @@
                                 # Keep the 'changed' version
                                prompt=lambda s, d: 'c\n')
         u, m, r, ur = self.client.update(rev2, clean=True)
-        self.assertEquals(u, 2)
-        self.assertEquals(m, 0)
-        self.assertEquals(r, 0)
-        self.assertEquals(ur, 0)
+        self.assertEqual(u, 2)
+        self.assertEqual(m, 0)
+        self.assertEqual(r, 0)
+        self.assertEqual(ur, 0)