[meld] Fix broken test, simplify test asserts and facilitate running tests.
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Fix broken test, simplify test asserts and facilitate running tests.
- Date: Sat, 30 May 2015 19:32:58 +0000 (UTC)
commit d470004d0eb80dddc9ca76f9d353ee69ca7fafb9
Author: Magnus Ihse Bursie <mag icus se>
Date: Fri May 8 01:54:29 2015 +0200
Fix broken test, simplify test asserts and facilitate running tests.
maint.py | 4 ++++
test/test_matchers.py | 28 ++++++++--------------------
2 files changed, 12 insertions(+), 20 deletions(-)
---
diff --git a/maint.py b/maint.py
index 4bc60e5..3a61f25 100755
--- a/maint.py
+++ b/maint.py
@@ -292,6 +292,10 @@ def push():
def cli():
pass
+ cli command()
+def test():
+ cmd = ['python', '-m', 'unittest', 'discover']
+ call_with_output(cmd, echo_stdout=True)
@cli.command()
def news():
diff --git a/test/__init__.py b/test/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/test/test_matchers.py b/test/test_matchers.py
index 178f2eb..c76d708 100644
--- a/test/test_matchers.py
+++ b/test/test_matchers.py
@@ -1,6 +1,6 @@
import unittest
-import matchers
+from meld import matchers
class MatchersTests(unittest.TestCase):
@@ -10,9 +10,7 @@ class MatchersTests(unittest.TestCase):
r = [(0, 2, 3), (4, 5, 3), (10, 8, 2), (15, 10, 0)]
matcher = matchers.MyersSequenceMatcher(None, a, b)
blocks = matcher.get_matching_blocks()
- self.assertEqual(len(blocks), len(r))
- for i in range(len(blocks)):
- self.assertEqual(blocks[i], r[i])
+ self.assertEqual(blocks, r)
def testPostprocessingCleanup(self):
a = list('abcfabgcd')
@@ -20,9 +18,7 @@ class MatchersTests(unittest.TestCase):
r = [(0, 2, 3), (4, 6, 3), (7, 12, 2), (9, 14, 0)]
matcher = matchers.MyersSequenceMatcher(None, a, b)
blocks = matcher.get_matching_blocks()
- self.assertEqual(len(blocks), len(r))
- for i in range(len(blocks)):
- self.assertEqual(blocks[i], r[i])
+ self.assertEqual(blocks, r)
def testInlineMatcher(self):
a = 'red, blue, yellow, white'
@@ -30,9 +26,7 @@ class MatchersTests(unittest.TestCase):
r = [(17, 16, 7), (24, 23, 0)]
matcher = matchers.InlineMyersSequenceMatcher(None, a, b)
blocks = matcher.get_matching_blocks()
- self.assertEqual(len(blocks), len(r))
- for i in range(len(blocks)):
- self.assertEqual(blocks[i], r[i])
+ self.assertEqual(blocks, r)
def testSyncPointMatcher0(self):
a = list('012a3456c789')
@@ -40,9 +34,7 @@ class MatchersTests(unittest.TestCase):
r = [(0, 0, 1), (3, 1, 3), (6, 7, 2), (9, 9, 2), (12, 11, 0)]
matcher = matchers.SyncPointMyersSequenceMatcher(None, a, b)
blocks = matcher.get_matching_blocks()
- self.assertEqual(len(blocks), len(r))
- for i in range(len(blocks)):
- self.assertEqual(blocks[i], r[i])
+ self.assertEqual(blocks, r)
def testSyncPointMatcher1(self):
a = list('012a3456c789')
@@ -50,19 +42,15 @@ class MatchersTests(unittest.TestCase):
r = [(0, 0, 1), (1, 4, 2), (6, 7, 2), (9, 9, 2), (12, 11, 0)]
matcher = matchers.SyncPointMyersSequenceMatcher(None, a, b, [(3,6)])
blocks = matcher.get_matching_blocks()
- self.assertEqual(len(blocks), len(r))
- for i in range(len(blocks)):
- self.assertEqual(blocks[i], r[i])
+ self.assertEqual(blocks, r)
def testSyncPointMatcher2(self):
a = list('012a3456c789')
b = list('02a341b5678')
- r = [(0, 0, 1), (2, 1, 4), (9, 9, 2), (12, 11, 0)]
+ r = [(0, 0, 1), (2, 1, 1), (3, 2, 3), (9, 9, 2), (12, 11, 0)]
matcher = matchers.SyncPointMyersSequenceMatcher(None, a, b, [(3,2), (8,6)])
blocks = matcher.get_matching_blocks()
- self.assertEqual(len(blocks), len(r))
- self.assertEqual(blocks[0], r[0])
- self.assertEqual(blocks[1], r[1])
+ self.assertEqual(blocks, r)
if __name__ == '__main__':
unittest.main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]