changeset 994:16ccaf7389d5 trunk

Fix text template inclusion tests so they work under Windows (being careful so that they still work under Python 3.x).
author hodgestar
date Sat, 26 Jan 2013 16:24:33 +0000
parents 8f00b78c6a59
children 0f4b2e892a48
files genshi/template/tests/text.py
diffstat 1 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/genshi/template/tests/text.py
+++ b/genshi/template/tests/text.py
@@ -94,17 +94,17 @@
 """, tmpl.generate(items=range(3)).render(encoding=None))
 
     def test_include(self):
-        file1 = open(os.path.join(self.dirname, 'tmpl1.txt'), 'w')
+        file1 = open(os.path.join(self.dirname, 'tmpl1.txt'), 'wb')
         try:
-            file1.write("Included\n")
+            file1.write(u"Included\n".encode("utf-8"))
         finally:
             file1.close()
 
-        file2 = open(os.path.join(self.dirname, 'tmpl2.txt'), 'w')
+        file2 = open(os.path.join(self.dirname, 'tmpl2.txt'), 'wb')
         try:
-            file2.write("""----- Included data below this line -----
+            file2.write(u"""----- Included data below this line -----
             #include tmpl1.txt
-            ----- Included data above this line -----""")
+            ----- Included data above this line -----""".encode("utf-8"))
         finally:
             file2.close()
 
@@ -219,17 +219,17 @@
         """, tmpl.generate().render(encoding=None))
 
     def test_include(self):
-        file1 = open(os.path.join(self.dirname, 'tmpl1.txt'), 'w')
+        file1 = open(os.path.join(self.dirname, 'tmpl1.txt'), 'wb')
         try:
-            file1.write("Included")
+            file1.write(u"Included".encode("utf-8"))
         finally:
             file1.close()
 
-        file2 = open(os.path.join(self.dirname, 'tmpl2.txt'), 'w')
+        file2 = open(os.path.join(self.dirname, 'tmpl2.txt'), 'wb')
         try:
-            file2.write("""----- Included data below this line -----
+            file2.write(u"""----- Included data below this line -----
 {% include tmpl1.txt %}
------ Included data above this line -----""")
+----- Included data above this line -----""".encode("utf-8"))
         finally:
             file2.close()
 
@@ -241,17 +241,17 @@
                          tmpl.generate().render(encoding=None))
 
     def test_include_expr(self):
-         file1 = open(os.path.join(self.dirname, 'tmpl1.txt'), 'w')
+         file1 = open(os.path.join(self.dirname, 'tmpl1.txt'), 'wb')
          try:
-             file1.write("Included")
+             file1.write(u"Included".encode("utf-8"))
          finally:
              file1.close()
  
-         file2 = open(os.path.join(self.dirname, 'tmpl2.txt'), 'w')
+         file2 = open(os.path.join(self.dirname, 'tmpl2.txt'), 'wb')
          try:
-             file2.write("""----- Included data below this line -----
+             file2.write(u"""----- Included data below this line -----
     {% include ${'%s.txt' % ('tmpl1',)} %}
-    ----- Included data above this line -----""")
+    ----- Included data above this line -----""".encode("utf-8"))
          finally:
              file2.close()
 
Copyright (C) 2012-2017 Edgewall Software