[Zope3-checkins] CVS: Zope3/src/zope/fssync/tests - test_merger.py:1.9
Guido van Rossum
guido@python.org
Thu, 15 May 2003 08:05:12 -0400
Update of /cvs-repository/Zope3/src/zope/fssync/tests
In directory cvs.zope.org:/tmp/cvs-serv22676
Modified Files:
test_merger.py
Log Message:
Do a proper test for diff3 support in all tests that need it.
=== Zope3/src/zope/fssync/tests/test_merger.py 1.8 => 1.9 ===
--- Zope3/src/zope/fssync/tests/test_merger.py:1.8 Wed May 14 18:16:09 2003
+++ Zope3/src/zope/fssync/tests/test_merger.py Thu May 15 08:05:12 2003
@@ -97,6 +97,24 @@
f2.close()
return data1 == data2
+ diff3ok = None
+
+ def check_for_diff3(self):
+ if self.diff3ok is None:
+ self.__class__.diff3ok = self.diff3_check()
+ return self.diff3ok
+
+ def diff3_check(self):
+ if not hasattr(os, "popen"):
+ return False
+ f1 = self.addfile("a")
+ f2 = self.addfile("b")
+ f3 = self.addfile("b")
+ pipe = os.popen("diff3 -m -E %s %s %s" % (f1, f2, f3), "r")
+ output = pipe.read()
+ sts = pipe.close()
+ return output == "b" and not sts
+
def runtest(self, localdata, origdata, remotedata,
localmetadata, remotemetadata, exp_localdata,
exp_action, exp_state, exp_merge_state=None):
@@ -184,14 +202,14 @@
self.runtest("a", "a", "ab", {}, {}, "ab", "Copy", "Uptodate")
def test_both_modified_resolved(self):
- if os.name != "posix":
- # Alas, this test requires the external command 'diff3'
- # which isn't usually found on Windows
+ if not self.check_for_diff3():
return
self.runtest("l\na\n", "a\n", "a\nr\n", {}, {},
"l\na\nr\n", "Merge", "Modified")
def test_both_modified_conflict(self):
+ if not self.check_for_diff3():
+ return
self.runtest("ab", "a", "ac", {}, {},
"", "Merge", "Modified", "Conflict")
@@ -205,6 +223,8 @@
self.runtest("a", None, "a", added, {}, "a", "Fix", "Uptodate")
def test_both_added_different(self):
+ if not self.check_for_diff3():
+ return
self.runtest("a", None, "b", added, {},
"", "Merge", "Modified", "Conflict")