代码之家  ›  专栏  ›  技术社区  ›  Jason S

使用init_模型中的模型对塔架应用程序进行鼻子测试?

  •  1
  • Jason S  · 技术社区  · 16 年前

    我有一个股票挂架应用程序创建使用 paster create -t pylons paster controller ,以及一个SQLAlchemy表和映射的ORM类。SQLAlchemy内容在 init_model() 功能,而不是在模块范围内(并且需要在模块范围内)。

    跑步 python setup.py test 引发异常,因为 nose 不知何故导致 init_模型() 在同一进程中被调用两次,因此它试图创建一个已经存在的模型。

    init_模型()

    鼻子 测试挂架,还是我应该编写自己的测试脚本并使用 unittest loadapp webtest 直接的?有这方面的工作实例吗?

    1 回复  |  直到 16 年前
        1
  •  3
  •   cmcginty    16 年前

    我会试着调试你的测试运行。为何不提出:

    import pdb;pdb.set_trace()
    

    init_model() 函数,并查看如何多次调用它。

    where

    w(here)
    Print a stack trace, with the most recent frame at the bottom.
    An arrow indicates the "current frame", which determines the
    context of most commands.  'bt' is an alias for this command.