[Pyunit-interest] PyunitBrowser 003 on win32
Brought to you by:
purcell
From: Syver E. <syv...@on...> - 2002-06-05 15:43:30
|
Note to Phlip: I understand that the PyUnitTestBrowser is written primarily for use on *nix machines, and by reporting problems found when running under win32 I don't therefore mean that you are in anyway obligated to fix them. I just report them in case you are interested in knowing about them. When run (version 003) from the site-packages/browser directory with the commandline: python browser.py I experience the following errors in test_browser.py (see bottom of mail) The fileNameToModuleName test case can be fixed by using os.sep in the construction of the test string Like this: got = fileNameToModuleName('.'+os.sep+'yak.py') instead of: got = fileNameToModuleName('./yak.py') But I think it would be better to use os.path.normpath in (fileNameToModuleName). os.path.normpath takes away unecessary path components too (like ./ and variations), so it's a nice tool to use in , since windows applications generally should handle both the fwd and the reverse slash (why does this remind of the lf/crlf problems, aargh!!) Here's the fix for the fileNameToModuleName function: def fileNameToModuleName(fileName): 'TODO is there a way in Python to avoid this drek??' assert fileName[-3:] == '.py' fileName = os.path.normpath(fileName) # fix by syver if fileName[0] != '.': fileName = '.' + os.sep + fileName fileName = fileName[:-3] moduleName = string.split(fileName, os.sep)[1:] moduleName = string.join(moduleName, '.') while moduleName[0] == '.': moduleName = moduleName[1:] return moduleName The windows version of the os.path module doesn't have the samefile method, only on *nix and mac methinks. The only help I can provide here would be to use the relative to absolute filename functions and then run os.path.normpath and then upper and compare the names. try: os.path.samefile(bla, bla) except AttributeError: # do smelly stuff here ====================================================================== FAIL: test_checkTime (test_browser.BrowserTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\devtools\Python22\Lib\site-packages\browser\test_browser.py", line 31 6, in test_checkTime same = os.path.samefile(file, _test_orangeHerring) AttributeError: 'module' object has no attribute 'samefile' ====================================================================== FAIL: test_fileNameToModuleName (test_browser.BrowserTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\devtools\Python22\Lib\site-packages\browser\test_browser.py", line 39 1, in test_fileNameToModuleName got = fileNameToModuleName('./yak.py') File "browser.py", line 400, in fileNameToModuleName while moduleName[0] == '.': moduleName = moduleName[1:] IndexError: string index out of range test_DB also fails with the following: ====================================================================== FAIL: test_db (test_Debug.DebugTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\devtools\Python22\Lib\site-packages\browser\test_Debug.py", line 34, in test_db self.assertEquals(self.myOutput, exp) File "d:\devtools\python22\lib\unittest.py", line 286, in failUnlessEqual raise self.failureException, \ AssertionError: 'D:\\devtools\\Python22\\Lib\\site-packages\\browser\\test_Debug .py:22: x = 10\nD:\\devtools\\Python22\\Lib\\site-packages\\browser\\test_Debug. py:24: x,y = (10,11)\nD:\\devtools\\Python22\\Lib\\site-packages\\browser\\test_ Debug.py:25: x,(y) = (10,11)\n' != 'test_Debug.py:22: x = 10\ntest_Debug.py:24: x,y = (10,11)\ntest_Debug.py:25: x,(y) = (10,11)\n' -- Vennlig hilsen Syver Enstad |