]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/tests/resolve_test.py
Remove string exception from remaster.
[wizard.git] / wizard / tests / resolve_test.py
index ba5c2ee0ebbc781c5023a39df167a832f24096e3..10067f9350f1a15781d2528e155a6bbc14bbdbd6 100644 (file)
@@ -1,33 +1,67 @@
+import unittest
+
 from wizard import resolve
 
-def test_resolve_simple():
-    contents = """
+class TestResolve(unittest.TestCase):
+
+    def test_resolve_simple(self):
+        contents = """
 foo
 bar
 <<<<<<< HEAD
 baz
+|||||||
+bal
 =======
 boo
 >>>>>>> upstream
 bing
 """
-    spec = """
+        spec = """
 <<<<<<<
 baz
 =======
 boo
 >>>>>>>
 """
-    result = [0]
-    assert resolve.resolve(contents, spec, result) == """
+        result = [0]
+        self.assertEqual(resolve.resolve(contents, spec, result), """
 foo
 bar
 boo
 bing
+""")
+
+    def test_resolve_simple_constrained(self):
+        contents = """
+1
+<<<<<<< HEAD
+2.1
+|||||||
+2
+=======
+2.a
+>>>>>>> upstream
+3
+"""
+        spec = """
+<<<<<<< HEAD
+2.1
+|||||||
+2
+=======
+2.a
+>>>>>>> upstream
 """
+        result = [0]
+        self.assertEqual(resolve.resolve(contents, spec, result), """
+1
+2.a
+3
+""")
 
-def test_resolve_wildcard():
-    contents = """
+    def test_resolve_wildcard(self):
+        contents = """
 foo
 bar
 <<<<<<< HEAD
@@ -35,13 +69,15 @@ common
 uncommon
 still uncommon
 
+|||||||
+something else
 =======
 transformed common
 >>>>>>> 456ef127bf8531bb363b1195172c71bce3747ae7
 baz
 """
 
-    spec = """
+        spec = """
 <<<<<<<
 common
 ***1***
@@ -50,8 +86,8 @@ transformed common
 >>>>>>>
 """
 
-    result = [0, 1]
-    assert resolve.resolve(contents, spec, result) == """
+        result = [0, 1]
+        self.assertEqual(resolve.resolve(contents, spec, result), """
 foo
 bar
 transformed common
@@ -59,25 +95,29 @@ uncommon
 still uncommon
 
 baz
-"""
+""")
 
-def test_resolve_user():
-    contents = """
+    def test_resolve_user(self):
+        contents = """
 top
 <<<<<<<
 bar
 the user is right
 baz
+|||||||
+something wonderful
 =======
 blah blah
 >>>>>>>
 bottom
 <<<<<<<
 Unrelated conflict
+|||||||
+something conflicty
 =======
 Unrelated conflicts
 >>>>>>>"""
-    spec = """
+        spec = """
 <<<<<<<
 ***1***
 the user is right
@@ -86,8 +126,8 @@ the user is right
 blah blah
 >>>>>>>
 """
-    result = [-1]
-    assert resolve.resolve(contents, spec, result) == """
+        result = [-1]
+        self.assertEqual(resolve.resolve(contents, spec, result), """
 top
 bar
 the user is right
@@ -95,18 +135,22 @@ baz
 bottom
 <<<<<<<
 Unrelated conflict
+|||||||
+something conflicty
 =======
 Unrelated conflicts
->>>>>>>"""
+>>>>>>>""")
 
-def test_resolve_multi_var():
-    contents = """
+    def test_resolve_multi_var(self):
+        contents = """
 top
 <<<<<<<
 the user is right
 this is ours
 more user stuff
 this is ours
+|||||||
+Something special?
 =======
 this is kept, but variable
 this is not kept
@@ -114,11 +158,13 @@ this is not kept
 bottom
 <<<<<<<
 unrelated conflict
+|||||||
+original text of unrelated conflict
 =======
 unrelated conflicts
 >>>>>>>
 """
-    spec = """
+        spec = """
 <<<<<<<
 ***1***
 this is ours
@@ -129,8 +175,8 @@ this is ours
 this is not kept
 >>>>>>>
 """
-    result = [3, 1, 2]
-    assert resolve.resolve(contents, spec, result) == """
+        result = [3, 1, 2]
+        self.assertEqual(resolve.resolve(contents, spec, result), """
 top
 this is kept, but variable
 the user is right
@@ -138,44 +184,52 @@ more user stuff
 bottom
 <<<<<<<
 unrelated conflict
+|||||||
+original text of unrelated conflict
 =======
 unrelated conflicts
 >>>>>>>
-"""
+""")
 
-def test_resolve_simple():
-    contents = """
+    def test_resolve_multi_simple(self):
+        contents = """
 bar
 <<<<<<< HEAD
 baz
+|||||||
+bollocks
 =======
 boo
 >>>>>>> upstream
 bing
 <<<<<<< HEAD
 oh?
+|||||||
+puntful
 =======
 bad match
 >>>>>>> upstream
 """
-    spec = """
+        spec = """
 <<<<<<<
 ***1***
 =======
 bad match
 >>>>>>>
 """
-    result = [-1]
-    assert resolve.resolve(contents, spec, result) == """
+        result = [-1]
+        self.assertEqual(resolve.resolve(contents, spec, result), """
 bar
 <<<<<<< HEAD
 baz
+|||||||
+bollocks
 =======
 boo
 >>>>>>> upstream
 bing
 oh?
-"""
+""")
 
 def test_is_conflict():
     assert not resolve.is_conflict("foobar\nbar")