Skip to content

Commit d470004

Browse files
magicuskaiw
authored andcommitted
Fix broken test, simplify test asserts and facilitate running tests.
1 parent 47844ef commit d470004

3 files changed

Lines changed: 12 additions & 20 deletions

File tree

maint.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ def push():
292292
def cli():
293293
pass
294294

295+
@cli.command()
296+
def test():
297+
cmd = ['python', '-m', 'unittest', 'discover']
298+
call_with_output(cmd, echo_stdout=True)
295299

296300
@cli.command()
297301
def news():

test/__init__.py

Whitespace-only changes.

test/test_matchers.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import unittest
3-
import matchers
3+
from meld import matchers
44

55
class MatchersTests(unittest.TestCase):
66

@@ -10,59 +10,47 @@ def testBasicMatcher(self):
1010
r = [(0, 2, 3), (4, 5, 3), (10, 8, 2), (15, 10, 0)]
1111
matcher = matchers.MyersSequenceMatcher(None, a, b)
1212
blocks = matcher.get_matching_blocks()
13-
self.assertEqual(len(blocks), len(r))
14-
for i in range(len(blocks)):
15-
self.assertEqual(blocks[i], r[i])
13+
self.assertEqual(blocks, r)
1614

1715
def testPostprocessingCleanup(self):
1816
a = list('abcfabgcd')
1917
b = list('afabcgabgcabcd')
2018
r = [(0, 2, 3), (4, 6, 3), (7, 12, 2), (9, 14, 0)]
2119
matcher = matchers.MyersSequenceMatcher(None, a, b)
2220
blocks = matcher.get_matching_blocks()
23-
self.assertEqual(len(blocks), len(r))
24-
for i in range(len(blocks)):
25-
self.assertEqual(blocks[i], r[i])
21+
self.assertEqual(blocks, r)
2622

2723
def testInlineMatcher(self):
2824
a = 'red, blue, yellow, white'
2925
b = 'black green, hue, white'
3026
r = [(17, 16, 7), (24, 23, 0)]
3127
matcher = matchers.InlineMyersSequenceMatcher(None, a, b)
3228
blocks = matcher.get_matching_blocks()
33-
self.assertEqual(len(blocks), len(r))
34-
for i in range(len(blocks)):
35-
self.assertEqual(blocks[i], r[i])
29+
self.assertEqual(blocks, r)
3630

3731
def testSyncPointMatcher0(self):
3832
a = list('012a3456c789')
3933
b = list('0a3412b5678')
4034
r = [(0, 0, 1), (3, 1, 3), (6, 7, 2), (9, 9, 2), (12, 11, 0)]
4135
matcher = matchers.SyncPointMyersSequenceMatcher(None, a, b)
4236
blocks = matcher.get_matching_blocks()
43-
self.assertEqual(len(blocks), len(r))
44-
for i in range(len(blocks)):
45-
self.assertEqual(blocks[i], r[i])
37+
self.assertEqual(blocks, r)
4638

4739
def testSyncPointMatcher1(self):
4840
a = list('012a3456c789')
4941
b = list('0a3412b5678')
5042
r = [(0, 0, 1), (1, 4, 2), (6, 7, 2), (9, 9, 2), (12, 11, 0)]
5143
matcher = matchers.SyncPointMyersSequenceMatcher(None, a, b, [(3,6)])
5244
blocks = matcher.get_matching_blocks()
53-
self.assertEqual(len(blocks), len(r))
54-
for i in range(len(blocks)):
55-
self.assertEqual(blocks[i], r[i])
45+
self.assertEqual(blocks, r)
5646

5747
def testSyncPointMatcher2(self):
5848
a = list('012a3456c789')
5949
b = list('02a341b5678')
60-
r = [(0, 0, 1), (2, 1, 4), (9, 9, 2), (12, 11, 0)]
50+
r = [(0, 0, 1), (2, 1, 1), (3, 2, 3), (9, 9, 2), (12, 11, 0)]
6151
matcher = matchers.SyncPointMyersSequenceMatcher(None, a, b, [(3,2), (8,6)])
6252
blocks = matcher.get_matching_blocks()
63-
self.assertEqual(len(blocks), len(r))
64-
self.assertEqual(blocks[0], r[0])
65-
self.assertEqual(blocks[1], r[1])
53+
self.assertEqual(blocks, r)
6654

6755
if __name__ == '__main__':
6856
unittest.main()

0 commit comments

Comments
 (0)