comparison tests/test_commit.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
comparison
equal deleted inserted replaced
220:ae6427d1c8f7 221:a2afbf236ca8
6 def test_user(self): 6 def test_user(self):
7 self.append('a', 'a') 7 self.append('a', 'a')
8 rev, node = self.client.commit(b('first'), addremove=True, 8 rev, node = self.client.commit(b('first'), addremove=True,
9 user=b('foo')) 9 user=b('foo'))
10 rev = self.client.log(node)[0] 10 rev = self.client.log(node)[0]
11 self.assertEquals(rev.author, b('foo')) 11 self.assertEqual(rev.author, b('foo'))
12 12
13 def test_no_user(self): 13 def test_no_user(self):
14 self.append('a', 'a') 14 self.append('a', 'a')
15 self.assertRaises(hglib.error.CommandError, 15 self.assertRaises(hglib.error.CommandError,
16 self.client.commit, b('first'), user=b('')) 16 self.client.commit, b('first'), user=b(''))
22 self.append('a', 'a') 22 self.append('a', 'a')
23 rev1, node1 = self.client.commit(b('second')) 23 rev1, node1 = self.client.commit(b('second'))
24 revclose = self.client.commit(b('closing foo'), closebranch=True) 24 revclose = self.client.commit(b('closing foo'), closebranch=True)
25 rev0, rev1, revclose = self.client.log([node0, node1, revclose[1]]) 25 rev0, rev1, revclose = self.client.log([node0, node1, revclose[1]])
26 26
27 self.assertEquals(self.client.branches(), 27 self.assertEqual(self.client.branches(),
28 [(rev0.branch, int(rev0.rev), rev0.node[:12])]) 28 [(rev0.branch, int(rev0.rev), rev0.node[:12])])
29 29
30 self.assertEquals(self.client.branches(closed=True), 30 self.assertEqual(self.client.branches(closed=True),
31 [(revclose.branch, int(revclose.rev), 31 [(revclose.branch, int(revclose.rev),
32 revclose.node[:12]), 32 revclose.node[:12]),
33 (rev0.branch, int(rev0.rev), rev0.node[:12])]) 33 (rev0.branch, int(rev0.rev), rev0.node[:12])])
34 34
35 def test_message_logfile(self): 35 def test_message_logfile(self):
42 now = datetime.datetime.now().replace(microsecond=0) 42 now = datetime.datetime.now().replace(microsecond=0)
43 rev0, node0 = self.client.commit( 43 rev0, node0 = self.client.commit(
44 b('first'), addremove=True, 44 b('first'), addremove=True,
45 date=now.isoformat(' ').encode('latin-1')) 45 date=now.isoformat(' ').encode('latin-1'))
46 46
47 self.assertEquals(now, self.client.tip().date) 47 self.assertEqual(now, self.client.tip().date)
48 48
49 def test_amend(self): 49 def test_amend(self):
50 self.append('a', 'a') 50 self.append('a', 'a')
51 now = datetime.datetime.now().replace(microsecond=0) 51 now = datetime.datetime.now().replace(microsecond=0)
52 rev0, node0 = self.client.commit( 52 rev0, node0 = self.client.commit(
53 b('first'), addremove=True, 53 b('first'), addremove=True,
54 date=now.isoformat(' ').encode('latin-1')) 54 date=now.isoformat(' ').encode('latin-1'))
55 55
56 self.assertEquals(now, self.client.tip().date) 56 self.assertEqual(now, self.client.tip().date)
57 57
58 self.append('a', 'a') 58 self.append('a', 'a')
59 rev1, node1 = self.client.commit(amend=True) 59 rev1, node1 = self.client.commit(amend=True)
60 self.assertEquals(now, self.client.tip().date) 60 self.assertEqual(now, self.client.tip().date)
61 self.assertNotEquals(node0, node1) 61 self.assertNotEqual(node0, node1)
62 self.assertEqual(1, len(self.client.log())) 62 self.assertEqual(1, len(self.client.log()))
63 63
64 def test_nul_injection(self): 64 def test_nul_injection(self):
65 self.append('a', 'a') 65 self.append('a', 'a')
66 self.assertRaises(ValueError, lambda: self.client.commit(b('fail\0-A'))) 66 self.assertRaises(ValueError, lambda: self.client.commit(b('fail\0-A')))