OperationalError: no such table: categories
The traceback shows that this comes from the get_category_options
function in controllers.py. The issue seems to be that this function
is called when Root is imported from bookmarker.controllers on line 2
of test_controllers.py.
I can't figure out why this function is called at all, because only
controllers.Root is imported, not the bookmark_fields class, which
contains the call to get_category_options.
Even when you use testutil.DBTest (in chapter 21) to ensure a database
exists, the problem doesn't go away because get_category_options is
called _before_ testutil.DBTest has a chance to create the temporary
database.
Is there a simple way to get around this problem? Also, why has
nobody else encountered it? Is it the versions of Python etc I'm
using?
Thanks
Barry
The full traceback is:
E
======================================================================
ERROR: test module bookmarker.tests.test_controllers in C:\bookmarker-
v3
----------------------------------------------------------------------
Traceback (most recent call last):
File "c:\python25\lib\site-packages\nose-0.9.3-py2.5.egg\nose
\suite.py", line 51, in run
self.setUp()
File "c:\python25\lib\site-packages\nose-0.9.3-py2.5.egg\nose
\suite.py", line 200, in setUp
self.module = _import(self.moduleName, [self.path], self.conf)
File "c:\python25\lib\site-packages\nose-0.9.3-py2.5.egg\nose
\importer.py", line 101, in _import
mod = load_module(fqname, fh, filename, desc)
File "C:\bookmarker-v3\bookmarker\tests\test_controllers.py", line
2, in <module>
from bookmarker.controllers import Root
File "C:\bookmarker-v3\bookmarker\controllers.py", line 16, in
<module>
class bookmark_fields(widgets.WidgetsList):
File "C:\bookmarker-v3\bookmarker\controllers.py", line 20, in
bookmark_fields
select_categories =
widgets.MultipleSelectField(options=get_category_options())
File "C:\bookmarker-v3\bookmarker\controllers.py", line 12, in
get_category_options
for category in categories:
File "c:\python25\lib\site-packages\SQLObject-0.9.0b2-py2.5.egg
\sqlobject\sresults.py", line 165, in __iter__
return iter(list(self.lazyIter()))
File "c:\python25\lib\site-packages\SQLObject-0.9.0b2-py2.5.egg
\sqlobject\sresults.py", line 173, in lazyIter
return conn.iterSelect(self)
File "c:\python25\lib\site-packages\SQLObject-0.9.0b2-py2.5.egg
\sqlobject\dbconnection.py", line 859, in iterSelect
select, keepConnection=True)))
File "c:\python25\lib\site-packages\SQLObject-0.9.0b2-py2.5.egg
\sqlobject\dbconnection.py", line 788, in __init__
self.dbconn._executeRetry(self.rawconn, self.cursor, self.query)
File "c:\python25\lib\site-packages\SQLObject-0.9.0b2-py2.5.egg
\sqlobject\sqlite\sqliteconnection.py", line 183, in _executeRetry
raise OperationalError(ErrorMessage(e))
OperationalError: no such table: categories
----------------------------------------------------------------------
Ran 0 tests in 4.276s
FAILED (errors=1)