Tim Peters wrote: > [Tim] > ... > >> So now I'm suspecting that the tricks in PthFile are managing to >>create a second instance of the time module not related to the >>instance of the time module test_strptime is monkey-patching with its >> >> time.tzname = (tz_name, tz_name) >> time.daylight = 1 >> >>tricks. > > > Using the attached patch yields output > > test___all__ > test_site > test_strptime > in strptime ('Eastern Standard Time', 'Eastern Daylight Time') 1 > in test_bad_timezone ('Eastern Standard Time', 'Eastern Standard Time') 1 > in strptime ('Eastern Standard Time', 'Eastern Daylight Time') 1 > ... > > so test_strptime's attempt to monkey-patch the time module indeed has > no effect on the time module _strptime.py is using. > Nuts. Some code somewhere must be importing strptime through time and that is holding a reference to the original copy of 'time' that was imported and then when test_site deletes sys.modules["time"] test_strptime imports 'time' again since it can't find a reference and uses that to monkey-patch which _strptime itself never sees since it holds the reference to the original imported 'time'. And I just re-read your previous email and you came to essentially the same conclusion as above. This just figures; only I could break my own test with another of my own tests. > The problem can be fixed by using this as the first line of test_bad_timezone: > > from _strptime import time > > But, of course, that's insane. > > >> But if so, I'm at a loss to explain why this would only >>happen on Windows. > > > Still so. > Stop wondering; it happens on OS X as well. OK, so the question becomes how can I have test_site (which I will fix with your suggestions for the removal of existing files and directories; when I rewrote that chunk of code I had EAFP on the brain) test to make sure that a module is imported? Is there any other way than to just try out another module that I think no one else is going mess with that has no importation side-effects? I guess I could have test_site just import site again in the .pth file. Could possibly use _strptime since I know I don't mess with that in any way. But is there some other way to check that I am not thinking of? -Brett
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4