Testing models with SQLAchemy 0.4

19 views
Skip to first unread message

iortega

unread,
Oct 9, 2007, 6:57:38 PM10/9/07
to pylons-discuss
I'm following the tutorial 'SQLAlchemy 0.4 for people in a hurry'. I
could configure sqlalchemy but when I tried to run nosetes this error
arises:

E
======================================================================
ERROR: Failure: exceptions.AttributeError('NoneType' object has no
attribute 'sa_engine')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/u/alfa/2004/iortega/lib/python2.4/site-packages/nose-0.10.0b1-
py2.4.egg/nose/loader.py", line 343, in loadTestsFromName
module = self.importer.importFromPath(
File "/u/alfa/2004/iortega/lib/python2.4/site-packages/nose-0.10.0b1-
py2.4.egg/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/u/alfa/2004/iortega/lib/python2.4/site-packages/nose-0.10.0b1-
py2.4.egg/nose/importer.py", line 84, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/u/alfa/2004/iortega/trunk/xriesgos/xriesgos/model/
__init__.py", line 6, in ?
Session = scoped_session(sessionmaker(autoflush=True,
transactional=True, bind=config['pylons.g'].sa_engine))
AttributeError: 'NoneType' object has no attribute 'sa_engine'

----------------------------------------------------------------------
Ran 1 test in 0.004s

How I can fix this error?

Thanks.

Ben Bangert

unread,
Oct 9, 2007, 9:00:02 PM10/9/07
to pylons-...@googlegroups.com
On Oct 9, 2007, at 3:57 PM, iortega wrote:

I'm following the tutorial 'SQLAlchemy 0.4 for people in a hurry'. I
could configure sqlalchemy but when I tried to run nosetes this error
arises:

Assuming you're running Pylons 0.9.6.1, add the following block to your setup.cfg:

[nosetests]
verbose=True
verbosity=2
with-pylons=test.ini
detailed-errors=1
with-doctest=False

Then run (this won't be needed in the next release):
sudo python setup.py develop

And you can now run nosetests like so:

python setup.py nosetests


I've updated the doc here to reflect this as well:

iortega

unread,
Oct 9, 2007, 9:05:43 PM10/9/07
to pylons-discuss
Yes, I'm running Pylons 0.9.6.1.
Your solution works!!!
Thanks!!!

> smime.p7s
> 3KDownload

nate...@gmail.com

unread,
Nov 14, 2007, 1:25:16 PM11/14/07
to pylons-discuss
Yes, that works for me too.

Why do you have to python setup.py develop and what does that do?

If I don't do that I get a traceback like this:
global_conf=global_conf)
File "/usr/lib/python2.5/site-packages/PasteDeploy-1.3.1-py2.5.egg/
paste/deploy/loadwsgi.py", line 274, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "/usr/lib/python2.5/site-packages/PasteDeploy-1.3.1-py2.5.egg/
paste/deploy/loadwsgi.py", line 542, in get_context
object_type, name=name)
File "/usr/lib/python2.5/site-packages/PasteDeploy-1.3.1-py2.5.egg/
paste/deploy/loadwsgi.py", line 562, in find_egg_entry_point
pkg_resources.require(self.spec)
File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 585,
in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 483,
in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: simpleauth

> smime.p7s
> 3KDownload

Agustin Villena

unread,
Nov 14, 2007, 7:16:56 PM11/14/07
to pylons-...@googlegroups.com
As far as I know, "python setup.py develop" registers the current project in
Python's 3rd parte repository (In windows normally is c:\python25\lib\site-packages),
creating a file named [your module].egg-link. In this file is stored the base path of your project.
When this file is created,  python  now can  find  your project when you import modules like
"import [your module].tests.mytest"



Agustin

Mike Orr

unread,
Nov 14, 2007, 10:15:17 PM11/14/07
to pylons-...@googlegroups.com
On Nov 14, 2007 4:16 PM, Agustin Villena <agustin...@gmail.com> wrote:
> As far as I know, "python setup.py develop" registers the current project in
> Python's 3rd parte repository (In windows normally is
> c:\python25\lib\site-packages),
> creating a file named [your module].egg-link. In this file is stored the
> base path of your project.
> When this file is created, python now can find your project when you
> import modules like
> "import [your module].tests.mytest"

It also makes sure the package's dependencies are installed, including
any indirect dependencies. "simpleauth" is apparently a dependency,
probably provided by another package.

If you change your package's dependencies (i.e., by editing setup.py),
running "python setup.py develop" again will bring your system up to
date.

--
Mike Orr <slugg...@gmail.com>

Reply all
Reply to author
Forward
0 new messages