2008/8/20 iain duncan <[EMAIL PROTECTED]>
>
> I have some functional tests that use twill to access my site. I'd like
> to use SA to also check whether the right things are happening in the
> database, but I am not able to import my model. If I run the tests from
> the main project directory by doing
>
> nosetests -s -v project/test_module.py
>
> and in test_module I am trying to import the model, I get the following:
>
> Traceback (most recent call last):
> File
> "/usr/lib/python2.4/site-projects/nose-0.10.3-py2.4.egg/nose/loader.py",
> line 363, in loadTestsFromName
> module = self.importer.importFromPath(
> File
> "/usr/lib/python2.4/site-projects/nose-0.10.3-py2.4.egg/nose/importer.py",
> line 39, in importFromPath
> return self.importFromDir(dir_path, fqname)
> File
> "/usr/lib/python2.4/site-projects/nose-0.10.3-py2.4.egg/nose/importer.py",
> line 84, in importFromDir
> mod = load_module(part_fqname, fh, filename, desc)
> File "/home/project/package-dev/package/tests/test_tfex_members.py",
> line 18, in ?
> from project.model import PaymentRequest
> File "/home/project/package-dev/package/model.py", line 40, in ?
> from model_identity import *
> File "/home/project/package-dev/package/model_identity.py", line 15,
> in ?
> bind_meta_data()
> File
> "/usr/lib/python2.4/site-projects/TurboGears-1.0.5-py2.4.egg/turbogears/database.py",
> line 42, in get_engine
> dburi = alch_args.pop('dburi')
> KeyError: 'pop(): dictionary is empty'
>
> Can anyone tell me how I can import the model from an external python
> app?
>
> Thanks!
> Iain
>
I don't know if my solution is optimal but I used something like that:
from turbogears import update_config, database, config
update_config(configfile='dev.cfg', modulename='vertimus.config')
from turbogears.database import session, get_engine
from vertimus.model import *
from sqlalchemy import and_
from sqlalchemy.orm import sessionmaker
# Do something with your session
# Raw SQL
conn = get_engine().connect()
conn.execute(something)
Stephane
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---