Changes between Initial Version and Version 18 of Ticket #11512
- Timestamp:
- Apr 16, 2014, 12:41:50 AM (10 years ago)
- Author:
- Ryan J Ollos
- Comment:
-
There is a problem after [12682]. Running the tests with a real SQLite db results in the following if
test.db
doesn't exist:$ make db=sqlite unit-test Python version: Python 2.7.4 figleaf: coverage: PYTHONPATH=.: TRAC_TEST_DB_URI=sqlite:test.db server-options= -p 8000 -a '*,~/tracenvs/htdigest.realm,realm' -r -e ~/tracenvs python setup.py egg_info running egg_info unrecognized .svn/entries format; skipping . writing requirements to Trac.egg-info/requires.txt writing Trac.egg-info/PKG-INFO writing top-level names to Trac.egg-info/top_level.txt writing dependency_links to Trac.egg-info/dependency_links.txt writing entry points to Trac.egg-info/entry_points.txt unrecognized .svn/entries format in /home/user/Workspace/t11584/teo-rjollos.git reading manifest file 'Trac.egg-info/SOURCES.txt' writing manifest file 'Trac.egg-info/SOURCES.txt' python ./trac/test.py --skip-functional-tests Traceback (most recent call last): File "./trac/test.py", line 478, in <module> unittest.main(defaultTest='suite') File "/usr/lib/python2.7/unittest/main.py", line 94, in __init__ self.parseArgs(argv) File "/usr/lib/python2.7/unittest/main.py", line 149, in parseArgs self.createTests() File "/usr/lib/python2.7/unittest/main.py", line 158, in createTests self.module) File "/usr/lib/python2.7/unittest/loader.py", line 128, in loadTestsFromNames suites = [self.loadTestsFromName(name, module) for name in names] File "/usr/lib/python2.7/unittest/loader.py", line 113, in loadTestsFromName test = obj() File "./trac/test.py", line 451, in suite suite.addTest(trac.tests.basicSuite()) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/tests/__init__.py", line 34, in basicSuite suite.addTest(wikisyntax.suite()) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/tests/wikisyntax.py", line 192, in suite suite.addTest(formatter.suite(SEARCH_TEST_CASES, file=__file__)) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/wiki/tests/formatter.py", line 303, in suite add_test_cases(data, file) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/wiki/tests/formatter.py", line 286, in add_test_cases teardown, context) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/wiki/tests/formatter.py", line 164, in __init__ self.env = EnvironmentStub(enable=['trac.*'] + all_test_components) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/core.py", line 124, in __call__ self.__init__(*args, **kwargs) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/test.py", line 319, in __init__ self.reset_db(default_data) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/test.py", line 337, in reset_db with self.db_transaction as db: File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/api.py", line 147, in __enter__ db = self.dbmgr.get_connection() File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/api.py", line 262, in get_connection db = self._cnx_pool.get_cnx(self.timeout or None) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/pool.py", line 213, in get_cnx return _backend.get_cnx(self._connector, self._kwargs, timeout) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/pool.py", line 134, in get_cnx raise TimeoutError(errmsg) trac.db.pool.TimeoutError: Unable to get database connection within 0 seconds. (TracError: Database "/home/user/Workspace/t11584/teo-rjollos.git/trac/test.db" not found.) make: *** [unit-test] Error 1
If
test.db
does exist:$ make db=sqlite unit-testPython version: Python 2.7.4 figleaf: coverage: PYTHONPATH=.: TRAC_TEST_DB_URI=sqlite:test.db server-options= -p 8000 -a '*,~/tracenvs/htdigest.realm,realm' -r -e ~/tracenvs python setup.py egg_info running egg_info unrecognized .svn/entries format; skipping . writing requirements to Trac.egg-info/requires.txt writing Trac.egg-info/PKG-INFO writing top-level names to Trac.egg-info/top_level.txt writing dependency_links to Trac.egg-info/dependency_links.txt writing entry points to Trac.egg-info/entry_points.txt unrecognized .svn/entries format in /home/user/Workspace/t11584/teo-rjollos.git reading manifest file 'Trac.egg-info/SOURCES.txt' writing manifest file 'Trac.egg-info/SOURCES.txt' python ./trac/test.py --skip-functional-tests ..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................EEE.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... ====================================================================== ERROR: test_empty_shared_htdocs_dir_raises_file_not_found (trac.web.tests.chrome.ChromeTestCase2) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/user/Workspace/t11584/teo-rjollos.git/trac/web/tests/chrome.py", line 352, in setUp self.env = EnvironmentStub(path=tempfile.mkdtemp()) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/core.py", line 124, in __call__ self.__init__(*args, **kwargs) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/test.py", line 319, in __init__ self.reset_db(default_data) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/test.py", line 337, in reset_db with self.db_transaction as db: File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/api.py", line 147, in __enter__ db = self.dbmgr.get_connection() File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/api.py", line 262, in get_connection db = self._cnx_pool.get_cnx(self.timeout or None) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/pool.py", line 213, in get_cnx return _backend.get_cnx(self._connector, self._kwargs, timeout) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/pool.py", line 134, in get_cnx raise TimeoutError(errmsg) TimeoutError: Unable to get database connection within 0 seconds. (TracError: Database "/tmp/tmpCaxBih/test.db" not found.) ====================================================================== ERROR: test_malicious_filename_raises (trac.web.tests.chrome.ChromeTestCase2) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/user/Workspace/t11584/teo-rjollos.git/trac/web/tests/chrome.py", line 352, in setUp self.env = EnvironmentStub(path=tempfile.mkdtemp()) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/core.py", line 124, in __call__ self.__init__(*args, **kwargs) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/test.py", line 319, in __init__ self.reset_db(default_data) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/test.py", line 337, in reset_db with self.db_transaction as db: File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/api.py", line 147, in __enter__ db = self.dbmgr.get_connection() File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/api.py", line 262, in get_connection db = self._cnx_pool.get_cnx(self.timeout or None) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/pool.py", line 213, in get_cnx return _backend.get_cnx(self._connector, self._kwargs, timeout) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/pool.py", line 134, in get_cnx raise TimeoutError(errmsg) TimeoutError: Unable to get database connection within 0 seconds. (TracError: Database "/tmp/tmp75oYjJ/test.db" not found.) ====================================================================== ERROR: test_shared_htdocs_dir_file_is_found (trac.web.tests.chrome.ChromeTestCase2) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/user/Workspace/t11584/teo-rjollos.git/trac/web/tests/chrome.py", line 352, in setUp self.env = EnvironmentStub(path=tempfile.mkdtemp()) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/core.py", line 124, in __call__ self.__init__(*args, **kwargs) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/test.py", line 319, in __init__ self.reset_db(default_data) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/test.py", line 337, in reset_db with self.db_transaction as db: File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/api.py", line 147, in __enter__ db = self.dbmgr.get_connection() File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/api.py", line 262, in get_connection db = self._cnx_pool.get_cnx(self.timeout or None) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/pool.py", line 213, in get_cnx return _backend.get_cnx(self._connector, self._kwargs, timeout) File "/home/user/Workspace/t11584/teo-rjollos.git/trac/db/pool.py", line 134, in get_cnx raise TimeoutError(errmsg) TimeoutError: Unable to get database connection within 0 seconds. (TracError: Database "/tmp/tmpbfHoUA/test.db" not found.) ---------------------------------------------------------------------- Ran 1545 tests in 76.798s FAILED (errors=3) make: *** [unit-test] Error 1
Shall we fix it by moving the context manager inside the
try
block?:-
trac/test.py
diff --git a/trac/test.py b/trac/test.py index 327f9d3..337249e 100755
a b class EnvironmentStub(Environment): 334 334 scheme, db_prop = _parse_db_str(self.dburi) 335 335 tables = [] 336 336 remove_sqlite_db = False 337 with self.db_transaction as db:338 try:337 try: 338 with self.db_transaction as db: 339 339 db.rollback() # make sure there's no transaction in progress 340 340 # check the database version 341 341 database_version = self.get_version() 342 except Exception: 343 # "Database not found ...", 344 # "OperationalError: no such table: system" or the like 345 pass 342 except Exception: 343 # "Database not found ...", 344 # "OperationalError: no such table: system" or the like 345 pass 346 else: 347 if database_version == db_default.db_version: 348 # same version, simply clear the tables (faster) 349 m = sys.modules[__name__] 350 reset_fn = 'reset_%s_db' % scheme 351 if hasattr(m, reset_fn): 352 tables = getattr(m, reset_fn)(self, db_prop) 346 353 else: 347 if database_version == db_default.db_version: 348 # same version, simply clear the tables (faster) 349 m = sys.modules[__name__] 350 reset_fn = 'reset_%s_db' % scheme 351 if hasattr(m, reset_fn): 352 tables = getattr(m, reset_fn)(self, db_prop) 353 else: 354 # different version or version unknown, drop the tables 355 remove_sqlite_db = True 356 self.destroy_db(scheme, db_prop) 354 # different version or version unknown, drop the tables 355 remove_sqlite_db = True 356 self.destroy_db(scheme, db_prop) 357 357 358 358 db = None # as we might shutdown the pool FIXME no longer needed!
-
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #11512
- Property Milestone 1.0.2 → 0.12.6
-
Ticket #11512 – API Changes
initial v18 1 * Added `drop_tables` method to the database connection classes. 2 * `update_sequence` method of the connection class uses the column name to select the max value. 3 * `update_sequence` and `get_last_id` methods of the connection classes and `trac.test.reset_postgres_db` quote the table and column names, fixing problems with upper case characters.