[Checkins] SVN: Products.GenericSetup/trunk/ Adjust test assertions in `test_differ` to cope with changes to the diff library done in Python 2.7.

Hanno Schlichting hannosch at hannosch.eu
Wed Sep 21 09:33:18 EST 2011


Log message for revision 122874:
  Adjust test assertions in `test_differ` to cope with changes to the diff library done in Python 2.7.
  

Changed:
  U   Products.GenericSetup/trunk/Products/GenericSetup/tests/test_differ.py
  U   Products.GenericSetup/trunk/docs/CHANGES.rst

-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tests/test_differ.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tests/test_differ.py	2011-09-21 14:25:05 UTC (rev 122873)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tests/test_differ.py	2011-09-21 14:33:18 UTC (rev 122874)
@@ -13,6 +13,7 @@
 """ Unit tests for differ module.
 """
 
+import sys
 import unittest
 from Testing.ZopeTestCase import ZopeTestCase
 
@@ -20,7 +21,9 @@
 from OFS.Folder import Folder
 from OFS.Image import File
 
+PYTHON27 = sys.version_info[:2] >= (2, 7)
 
+
 class DummySite( Folder ):
 
     pass
@@ -34,7 +37,10 @@
 
         diff_lines = unidiff( ONE_FOUR, ZERO_FOUR )
         diff_text = '\n'.join( diff_lines )
-        self.assertEqual( diff_text, DIFF_TEXT )
+        if PYTHON27:
+            self.assertEqual( diff_text, DIFF_TEXT_27 )
+        else:
+            self.assertEqual( diff_text, DIFF_TEXT )
 
     def test_unidiff_both_lines( self ):
 
@@ -42,7 +48,10 @@
 
         diff_lines = unidiff( ONE_FOUR.splitlines(), ZERO_FOUR.splitlines() )
         diff_text = '\n'.join( diff_lines )
-        self.assertEqual( diff_text, DIFF_TEXT )
+        if PYTHON27:
+            self.assertEqual( diff_text, DIFF_TEXT_27 )
+        else:
+            self.assertEqual( diff_text, DIFF_TEXT )
 
     def test_unidiff_mixed( self ):
 
@@ -50,7 +59,10 @@
 
         diff_lines = unidiff( ONE_FOUR, ZERO_FOUR.splitlines() )
         diff_text = '\n'.join( diff_lines )
-        self.assertEqual( diff_text, DIFF_TEXT )
+        if PYTHON27:
+            self.assertEqual( diff_text, DIFF_TEXT_27 )
+        else:
+            self.assertEqual( diff_text, DIFF_TEXT )
 
     def test_unidiff_ignore_blanks( self ):
 
@@ -63,7 +75,10 @@
                             )
 
         diff_text = '\n'.join( diff_lines )
-        self.assertEqual( diff_text, DIFF_TEXT )
+        if PYTHON27:
+            self.assertEqual( diff_text, DIFF_TEXT_27 )
+        else:
+            self.assertEqual( diff_text, DIFF_TEXT )
 
 ZERO_FOUR = """\
 zero
@@ -91,6 +106,19 @@
  four\
 """
 
+DIFF_TEXT_27 = """\
+--- original
++++ modified
+@@ -1,4 +1,4 @@
++zero
+ one
+-two
+-three
++tree
+ four\
+"""
+
+
 class ConfigDiffTests(ZopeTestCase):
 
     site = None
@@ -214,7 +242,10 @@
 
         diffs = cd.compare()
 
-        self.assertEqual( diffs, TEST_TXT_DIFFS % ( BEFORE, AFTER ) )
+        if PYTHON27:
+            self.assertEqual( diffs, TEST_TXT_DIFFS_27 % ( BEFORE, AFTER ) )
+        else:
+            self.assertEqual( diffs, TEST_TXT_DIFFS % ( BEFORE, AFTER ) )
 
     def test_compare_changed_file_ignore_blanks( self ):
 
@@ -310,7 +341,10 @@
 
         diffs = cd.compare()
 
-        self.assertEqual( diffs, ADDED_FILE_DIFFS_MAE % AFTER )
+        if PYTHON27:
+            self.assertEqual( diffs, ADDED_FILE_DIFFS_MAE_27 % AFTER )
+        else:
+            self.assertEqual( diffs, ADDED_FILE_DIFFS_MAE % AFTER )
 
     def test_compare_removed_file_no_missing_as_empty( self ):
 
@@ -344,7 +378,10 @@
 
         diffs = cd.compare()
 
-        self.assertEqual( diffs, REMOVED_FILE_DIFFS_MAE % BEFORE )
+        if PYTHON27:
+            self.assertEqual( diffs, REMOVED_FILE_DIFFS_MAE_27 % BEFORE )
+        else:
+            self.assertEqual( diffs, REMOVED_FILE_DIFFS_MAE % BEFORE )
 
 
 TEST_TXT_DIFFS = """\
@@ -358,6 +395,17 @@
 +QRST\
 """
 
+TEST_TXT_DIFFS_27 = """\
+Index: test.txt
+===================================================================
+--- test.txt\t%s
++++ test.txt\t%s
+@@ -1,2 +1,2 @@
+ ABCDEF
+-WXYZ
++QRST\
+"""
+
 ADDED_FILE_DIFFS_NO_MAE = """\
 ** File sub/again.txt added
 """
@@ -371,6 +419,15 @@
 +GHIJKL\
 """
 
+ADDED_FILE_DIFFS_MAE_27 = """\
+Index: sub/again.txt
+===================================================================
+--- sub/again.txt
++++ sub/again.txt\t%s
+@@ -0,0 +1 @@
++GHIJKL\
+"""
+
 REMOVED_FILE_DIFFS_NO_MAE = """\
 ** File sub/again.txt removed
 """
@@ -384,7 +441,16 @@
 -GHIJKL\
 """
 
+REMOVED_FILE_DIFFS_MAE_27 = """\
+Index: sub/again.txt
+===================================================================
+--- sub/again.txt\t%s
++++ sub/again.txt
+@@ -1 +0,0 @@
+-GHIJKL\
+"""
 
+
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite(Test_unidiff),

Modified: Products.GenericSetup/trunk/docs/CHANGES.rst
===================================================================
--- Products.GenericSetup/trunk/docs/CHANGES.rst	2011-09-21 14:25:05 UTC (rev 122873)
+++ Products.GenericSetup/trunk/docs/CHANGES.rst	2011-09-21 14:33:18 UTC (rev 122874)
@@ -4,6 +4,9 @@
 1.6.4 (unreleased)
 ------------------
 
+- Adjust test assertions in `test_differ` to cope with changes to the diff
+  library done in Python 2.7.
+
 - LP #850665:  match permission binding to method name.
 
 - LP #602989:  export / import new MailHost properties, `smtp_queue` and



More information about the checkins mailing list