#9682 closed defect (fixed)
Test suite fails on Python 2.7
Reported by: | Remy Blank | Owned by: | Remy Blank |
---|---|---|---|
Priority: | normal | Milestone: | 0.12.2 |
Component: | general | Version: | 0.12-stable |
Severity: | normal | Keywords: | python27 |
Cc: | Branch: | ||
Release Notes: |
Fixed test suite failure on Python 2.7. |
||
API Changes: | |||
Internal Changes: |
Description
The test suite has been reported by the Gentoo Linux project to fail on Python 2.7:
Traceback (most recent call last): File "trac/test.py", line 441, in <module> unittest.main(defaultTest='suite') File "/usr/lib64/python2.7/unittest/main.py", line 95, in __init__ self.runTests() File "/usr/lib64/python2.7/unittest/main.py", line 229, in runTests self.result = testRunner.run(self.test) File "/usr/lib64/python2.7/unittest/runner.py", line 151, in run test(result) File "/usr/lib64/python2.7/unittest/suite.py", line 65, in __call__ return self.run(*args, **kwds) File "/usr/lib64/python2.7/unittest/suite.py", line 85, in run self._wrapped_run(result) File "/usr/lib64/python2.7/unittest/suite.py", line 115, in _wrapped_run test._wrapped_run(result, debug) File "/usr/lib64/python2.7/unittest/suite.py", line 115, in _wrapped_run test._wrapped_run(result, debug) File "/usr/lib64/python2.7/unittest/suite.py", line 115, in _wrapped_run test._wrapped_run(result, debug) File "/usr/lib64/python2.7/unittest/suite.py", line 115, in _wrapped_run test._wrapped_run(result, debug) TypeError: _wrapped_run() takes exactly 2 arguments (3 given)
Attachments (0)
Change History (13)
comment:2 by , 14 years ago
Fix confirmed on my side, test suite pass (only in-memory SQLite tested so far, "bigtest" in progress). I suppose that correspond to a last minute change on their side between rc2 and final (I had rc2 installed until this week-end, and I'm pretty sure I tested 0.12 with that one).
So this is just a unittest induced glitch, no need to modify anything in the release notes, Trac 0.12.1, as did 0.12 before, works perfectly well with Python 2.7.
follow-up: 5 comment:3 by , 14 years ago
Scratch that… I specified python=27 but 2.6.5 was used due to a misconfiguration.
comment:4 by , 14 years ago
Thanks for testing. I noticed another (unrelated) issue with Python 2.7 on Windows 7. Every second run of the test suite fails on creation of the testenv
folder. After the failure, the folder disappears, so the next run passes.
Looking at the code, the corresponding line looks very suspect, as os.mkdir()
isn't supposed to return anything. I haven't had time to investigate further.
follow-ups: 8 12 comment:5 by , 14 years ago
Ok, there's apparently a different problem when running the tests using the following command line:
$ python ./trac/test.py --skip-functional-tests Traceback (most recent call last): File "./trac/test.py", line 427, in <module> unittest.main(defaultTest='suite') File "C:\Dev\Python27\lib\unittest\main.py", line 94, in __init__ self.parseArgs(argv) File "C:\Dev\Python27\lib\unittest\main.py", line 149, in parseArgs self.createTests() File "C:\Dev\Python27\lib\unittest\main.py", line 158, in createTests self.module) File "C:\Dev\Python27\lib\unittest\loader.py", line 128, in loadTestsFromNames suites = [self.loadTestsFromName(name, module) for name in names] File "C:\Dev\Python27\lib\unittest\loader.py", line 113, in loadTestsFromName test = obj() File "./trac/test.py", line 392, in suite import trac.tests ImportError: No module named tests
No idea why, yet.
But it works fine using python -m trac.test
or even python setup.py test
.
This way, all unit tests pass, and the functional tests need the patch from comment:1.
Tested on Windows 7 (x64) with Python 2.7 (x86):
- OK for sqlite::memory: with the builtin sqlite
- OK for mysql: with MySQLdb 1.2.3
- OK for postgresql: with psycopg2-2.2.2 (well, I actually have 11 failures, but they are all due to the switch to 9.0.1, no real failure; fixes for the failing tests will come separately)
- FAIL for sqlite:test27.db (builtin sqlite)
Initenv for 'C:\Workspace\src\trac\repos\trunk\testenv\trac' failed. Failed to create environment. [Error 183] Cannot create a file when that file already exists: u'C:\\Workspace\\src\\trac\\repos\\trunk\\testenv\\trac'
Perhaps this is related to the issue you mentioned in comment:4? But it happens systematically for me (and 2.6.5 works fine for this new backend)
I didn't test the following:
SKIP: versioncontrol/tests/functional.py (no svn bindings) SKIP: versioncontrol/tests/svn_fs.py (no svn bindings) SKIP: tracopt/mimeview/tests/php.py (php cli binary, 'php', not found)
Python 2.7 bindings for Subversion, anyone?
follow-up: 9 comment:7 by , 14 years ago
Here's the traceback for the issue I mentioned in comment:4:
Traceback (most recent call last): File "trac\test.py", line 441, in <module> unittest.main(defaultTest='suite') File "C:\Python27\Lib\unittest\main.py", line 95, in __init__ self.runTests() File "C:\Python27\Lib\unittest\main.py", line 229, in runTests self.result = testRunner.run(self.test) File "C:\Python27\Lib\unittest\runner.py", line 151, in run test(result) File "C:\Python27\Lib\unittest\suite.py", line 65, in __call__ return self.run(*args, **kwds) File "C:\Python27\Lib\unittest\suite.py", line 85, in run self._wrapped_run(result) File "C:\Python27\Lib\unittest\suite.py", line 115, in _wrapped_run test._wrapped_run(result, debug) File "C:\Python27\Lib\unittest\suite.py", line 115, in _wrapped_run test._wrapped_run(result, debug) File "Z:\src\trac\0.12-stable-2.7\trac\test.py", line 144, in _wrapped_run self.setUp() File "Z:\src\trac\0.12-stable-2.7\trac\tests\functional\__init__.py", line 121, in setUp self._testenv = self.env_class(dirname, port, baseurl) File "Z:\src\trac\0.12-stable-2.7\trac\tests\functional\testenv.py", line 58, in __init__ self.create() File "Z:\src\trac\0.12-stable-2.7\trac\tests\functional\testenv.py", line 114, in create if os.mkdir(self.dirname): WindowsError: [Error 5] Access is denied: 'Z:\\src\\trac\\0.12-stable-2.7\\testenv'
It seems this has nothing to do with Python 2.7, and everything with Windows (or VirtualBox). The "access denied" error comes from the testenv
directory not being removed completely when the os.rmdir()
call returns (possibly due to Windows Explorer), and the subsequent os.mkdir()
being denied creation.
Start the following program on Windows 7 from the command-line, with no Windows Explorer windows open:
import os path = 'testenv' while True: try: os.rmdir(path) except OSError: pass os.mkdir(path)
Nothing happens, the directory is created and destroyed repeatedly. Now, open a Windows Explorer window and navigate to the directory where you launched the script, and expand that folder in the tree view on the left. Here (Windows 7 VM on VirtualBox), the script traps within a few seconds. The symptom is the same with both Python 2.6 and 2.7.
Adding even a very small pause (1 ms) before the os.mkdir()
fixes the issue. So I suggest the following patch:
-
trac/tests/functional/testenv.py
diff --git a/trac/tests/functional/testenv.py b/trac/tests/functional/testenv.py
a b class FunctionalTestEnvironment(object): 55 55 self.pid = None 56 56 self.init() 57 57 self.destroy() 58 time.sleep(0.1) # Avoid race condition on Windows 58 59 self.create() 59 60 locale.setlocale(locale.LC_ALL, '') 60 61
comment:8 by , 14 years ago
- OK for postgresql: with psycopg2-2.2.2 (well, I actually have 11 failures, but they are all due to the switch to 9.0.1, no real failure; fixes for the failing tests will come separately)
follow-up: 11 comment:9 by , 14 years ago
Replying to rblank:
Here's the traceback for the issue I mentioned in comment:4:
I didn't observe that error, but:
The "access denied" error comes from the
testenv
directory not being removed completely when theos.rmdir()
call returns (possibly due to Windows Explorer), and the subsequentos.mkdir()
being denied creation.
I can see that as well with plain Windows 7, with the test script.
Adding even a very small pause (1 ms) before the
os.mkdir()
fixes the issue.
Should work fine, please commit.
Unfortunately, the error I mentioned in comment:5 for the sqlite: backend is still there, so it must be a different issue.
comment:11 by , 14 years ago
comment:12 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Replying to cboos:
- FAIL for sqlite:test27.db (builtin sqlite)
Initenv for 'C:\Workspace\src\trac\repos\trunk\testenv\trac' failed. Failed to create environment. [Error 183] Cannot create a file when that file already exists: u'C:\\Workspace\\src\\trac\\repos\\trunk\\testenv\\trac'
That one was due to the SQLite connector trying to os.makedirs()
an existing directory. Running with sqlite:db\test27.db
works great. I have fixed the issue in [10231], and removed the suspect code from comment:4 in [10232].
comment:13 by , 14 years ago
Release Notes: | modified (diff) |
---|
The following patch fixes the issue for me:
trac/test.py
result):result)return result