[py-svn] r34924 - in py/dist/py/apigen/rest: . testing

guido at codespeak.net guido at codespeak.net
Thu Nov 23 23:12:01 CET 2006


Author: guido
Date: Thu Nov 23 23:11:59 2006
New Revision: 34924

Modified:
   py/dist/py/apigen/rest/genrest.py
   py/dist/py/apigen/rest/testing/test_rest.py
Log:
Fixed tests for win32, fixed problem with path to URL conversion in win32

Modified: py/dist/py/apigen/rest/genrest.py
==============================================================================
--- py/dist/py/apigen/rest/genrest.py	(original)
+++ py/dist/py/apigen/rest/genrest.py	Thu Nov 23 23:11:59 2006
@@ -44,6 +44,9 @@
         relname = filename[len(path):]
         if relname.endswith('.pyc'):
             relname = relname[:-1]
+        sep = py.std.os.sep
+        if sep != '/':
+            relname = relname.replace(sep, '/')
         return ('%s:%s' % (filename, lineno),
                 self.basepath + relname[1:] + '?view=markup')
 

Modified: py/dist/py/apigen/rest/testing/test_rest.py
==============================================================================
--- py/dist/py/apigen/rest/testing/test_rest.py	(original)
+++ py/dist/py/apigen/rest/testing/test_rest.py	Thu Nov 23 23:11:59 2006
@@ -18,6 +18,12 @@
 from py.__.rest.transform import HTMLHandler
 # XXX: UUuuuuuuuuuuuuuuuuuuuuuuu, dangerous import
 
+def _nl(s):
+    """normalize newlines (converting to \n)"""
+    s = s.replace('\r\n', '\n')
+    s = s.replace('\r', '\n')
+    return s
+
 def setup_module(mod):
     mod.temppath = py.test.ensuretemp('restgen')
 
@@ -86,8 +92,8 @@
         fpaths = tempdir.listdir('*.txt')
         assert len(fpaths) == 2
         assert sorted([f.basename for f in fpaths]) == ['bar.txt', 'foo.txt']
-        assert tempdir.join('foo.txt').read() == 'foo data\n'
-        assert tempdir.join('bar.txt').read() == 'bar data\n'
+        assert _nl(tempdir.join('foo.txt').read()) == 'foo data\n'
+        assert _nl(tempdir.join('bar.txt').read()) == 'bar data\n'
     
     def test_getlink(self):
         dw = DirWriter(temppath.join('dirwriter_getlink'))
@@ -239,7 +245,7 @@
         r.write()
         index = tempdir.join('module_Unknown module.txt')
         assert index.check(file=True)
-        data = index.read()
+        data = _nl(index.read())
         assert data.find('.. _`fun`: function_fun.html\n') > -1
         assert data.find('.. _`fun`: #function-fun\n') == -1
 
@@ -247,7 +253,7 @@
                                   file=True)
         r = RestGen(ds, lg, FileWriter(tempfile))
         r.write()
-        data = tempfile.read()
+        data = _nl(tempfile.read())
         assert data.find('.. _`fun`: #function-fun\n') > -1
         assert data.find('.. _`fun`: function_fun.html') == -1
 
@@ -256,7 +262,7 @@
         tempfile = temppath.join('internal_links.txt')
         if not tempfile.check():
             py.test.skip('depends on previous test, which failed')
-        data = tempfile.read()
+        data = _nl(tempfile.read())
         # index should be above the rest
         print data
         assert data.find('classes\\:') > -1



More information about the pytest-commit mailing list