Thread: [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 |
From: Phlip <ppl...@om...> - 2002-06-05 16:38:17
|
Syver Enstad sez: > 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. Then you misunderstand me. I intend to ask Steve to add this to PyUnit, under a folder called contrib/browser. And I intend to port it to wherever Python & Tkinter go. To do that I need to remove Pmw, and get these idiotic path issues fixed. > 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) I have been sneakily upgrading those temporary "releases" if I improve them but don't add anything radical or contradict the documentation. Please try one of these: http://flea.sourceforge.net/browser003.zip http://flea.sourceforge.net/browser.zip The latter is my latest bench version - the equivalent of a CVS HEAD. > The fileNameToModuleName test case can be fixed by > using os.sep in the construction of the test string This has been fixed, test-first. So the tests should reveal that stoopid function working with a range of kinds of relative file locations. > fileName = os.path.normpath(fileName) # fix by syver I will add this (with the attribution ;-) the next time I'm working on the module. > if fileName[0] != '.': fileName = '.' + os.sep + fileName Yeek! You just took it off so we can put it on again! The only reason it's there is to hard-code the [1:] two lines down! > fileName = fileName[:-3] > moduleName = string.split(fileName, os.sep)[1:] > The windows version of the os.path module doesn't have the samefile > method, only on *nix and mac methinks. Translation: It works by checking the inode; Windowz and mac don't have them but do have absolute jiggers built into their directory system, and the Python guys didn't feel like research this. Thanks for the error traces; I'l see when I have time ;-) -- Phlip http://www.greencheese.org/DontPlanDesigns "I love children, especially when they cry, for then someone takes them away." -- Nancy Mitford |
From: Syver E. <syv...@on...> - 2002-06-05 17:14:54
|
Phlip <ppl...@om...> writes: > > > fileName = os.path.normpath(fileName) # fix by syver > > I will add this (with the attribution ;-) the next time I'm working on > the module. No please, don't put my attribution there, it's just to point the way to where I've changed things from the original source (I don't speak diff as fluently as others around here). The last time I did that, the comment got into the win32com sources, and it looks really silly. So please remove the comment, Okay??? -- Vennlig hilsen Syver Enstad |