Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1339 (closed defect: invalid)

Opened 12 years ago

Last modified 12 years ago

nosetests fail with sqlalchemy / Elixir

Reported by: nerkles Owned by: anonymous
Priority: normal Milestone: 1.0.2
Component: Tests Version: 1.0
Severity: normal Keywords:


When running nosetests with an SA or Elixir (or a little of both) model, nosetests will fail with this error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/nose-0.9.2-py2.5.egg/nose/case.py",
line 129, in setUp
    try_run(self.testInstance, names)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/nose-0.9.2-py2.5.egg/nose/util.py",
line 210, in try_run
    return func()
  File "/Users/Shared/tgdev/svn_working/my_project/trunk/my_project-sa2/my_projectsa2/tests/utils_database.py",
line 11, in setUp
  File "/Users/Shared/tgdev/svn_working/tg1.0/turbogears/database.py",
line 57, in bind_meta_data
  File "/Users/Shared/tgdev/svn_working/tg1.0/turbogears/database.py",
line 39, in get_engine
    dburi = alch_args.pop('dburi')
KeyError: 'pop(): dictionary is empty'

So it seems to miss the dburi from test.cfg.

I fixed it temporarily by changing line 39 of database.py to:

            dburi = alch_args.pop('dburi', 'sqlite:///:memory:') 

(it doesn't seem to bother non-testing runs).

Anyway, that fix works but it's obviously far from ideal.

Discussion on this thread of the Elixir list, including some example code to get a working setUp and tearDown with Elixir/SA:


Change History

comment:1 Changed 12 years ago by mnewby

  • Status changed from new to closed
  • Resolution set to invalid

Though this doesn't appear to be documented (outside the source anyway), test.cfg is only used if the turbogears.testutil module is loaded. All test modules that want configuration from test.cfg should make sure to import testutil.

Note: See TracTickets for help on using tickets.