Tests for pyramid app fail if reexecuted using sniffer

200 views Asked by At

I just started to get my testing environment for a pyramid web app up and running. I have just a few basic tests, including some examples created by the pyramid paster template. If I run them via nosetest everything works fine.

If I run them via sniffer, the first run works fine too. But if I change my code and sniffer runs the tests again, I get the following stack trace:

======================================================================
ERROR: Failure: TypeError (isinstance() arg 2 must be a class, type, or tuple of classes and types)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/domma/Develop/WebApps/Gligg/gligg_env/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/Users/domma/Develop/WebApps/Gligg/gligg_env/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/Users/domma/Develop/WebApps/Gligg/gligg_env/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/Users/domma/Develop/WebApps/Gligg/Gligg/gligg/__init__.py", line 1, in <module>
    from pyramid.config import Configurator
  File "/Users/domma/Develop/WebApps/Gligg/gligg_env/lib/python2.7/site-packages/pyramid/__init__.py", line 1, in <module>
    from pyramid.request import Request
  File "/Users/domma/Develop/WebApps/Gligg/gligg_env/lib/python2.7/site-packages/pyramid/request.py", line 27, in <module>
    from pyramid.response import Response
  File "/Users/domma/Develop/WebApps/Gligg/gligg_env/lib/python2.7/site-packages/pyramid/response.py", line 28, in <module>
    class Response(_Response):
  File "/Users/domma/Develop/WebApps/Gligg/gligg_env/lib/python2.7/site-packages/zope/interface/declarations.py", line 306, in __call__
    classImplements(ob, *self.interfaces)
  File "/Users/domma/Develop/WebApps/Gligg/gligg_env/lib/python2.7/site-packages/zope/interface/declarations.py", line 244, in classImplements
    spec = implementedBy(cls)
  File "/Users/domma/Develop/WebApps/Gligg/gligg_env/lib/python2.7/site-packages/zope/interface/declarations.py", line 169, in implementedByFallback
    if isinstance(spec, Implements):
TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types

----------------------------------------------------------------------

In my setUp I have:

self.config = testing.setUp()
engine = create_engine('sqlite://')        
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)

And in my tearDown:

DBSession.remove()
testing.tearDown()

The error already occures in the import of Configurator, so I would guess I miss some cleanup code which resets some internals. But I have no idea what it might be. Any hint would be very welcome!

1

There are 1 answers

0
Michael Merickel On

This sounds like some odd behavior within sniffer where it isn't properly reloading the app between runs. Your teardown code looks fine and should close the outstanding database connection in the current thread as well as pop any threadlocals used by Pyramid.