【问题标题】:Tests for pyramid app fail if reexecuted using sniffer如果使用嗅探器重新执行金字塔应用程序的测试将失败
【发布时间】:2012-10-20 09:54:29
【问题描述】:

我刚刚开始为金字塔网络应用程序建立并运行我的测试环境。我只有一些基本的测试,包括金字塔贴纸模板创建的一些示例。如果我通过nosetest 运行它们,一切正常。

如果我通过sniffer 运行它们,第一次运行也可以正常运行。但是如果我更改我的代码并且嗅探器再次运行测试,我会得到以下堆栈跟踪:

======================================================================
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

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

在我的设置中,我有:

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

在我的拆解中:

DBSession.remove()
testing.tearDown()

Configurator 的导入中已经发生错误,所以我想我错过了一些重置一些内部的清理代码。但我不知道它可能是什么。任何提示都会非常受欢迎!

【问题讨论】:

    标签: python testing pyramid zope.interface


    【解决方案1】:

    这听起来像是嗅探器中的一些奇怪行为,它在运行之间没有正确重新加载应用程序。您的拆卸代码看起来不错,应该关闭当前线程中未完成的数据库连接,并弹出 Pyramid 使用的任何线程本地。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-04-21
      • 1970-01-01
      • 2013-06-26
      • 1970-01-01
      • 2011-02-23
      • 2012-10-21
      • 2012-11-23
      相关资源
      最近更新 更多