【问题标题】:Django tests fail on Postgresql (8.4) - Flushing DB causes errorDjango 测试在 Postgresql (8.4) 上失败 - 刷新数据库导致错误
【发布时间】:2011-09-07 14:26:36
【问题描述】:

尝试在 PostgreSQL 后端为项目运行 DJ 测试时,我遇到了一个非常烦人的问题。它开始运行测试,当第一次刷新数据库时,它会失败并出现一个奇怪的错误:

..Error: Database dbname couldn't be flushed. Possible reasons:
  * The database isn't running or isn't configured correctly.
  * At least one of the expected database tables doesn't exist.
  * The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
The full error: cannot TRUNCATE "table_name" because it has pending trigger events

如果我通过 pgAdmin 运行 sqlflush 的输出,它运行得很好。

欢迎对可能的原因提出任何想法。

更新:

好的,看起来这实际上不是 Django 的问题,而是与 djangosanetesting 中的测试运行程序有关。使用默认的 DJ 测试运行器或 django-nose 测试运行器它可以工作。

【问题讨论】:

    标签: python database django postgresql testing


    【解决方案1】:

    好的,看起来这实际上不是 Django 的问题,而是与 djangosanetesting 中的测试运行程序有关,其中刷新似乎在某种程度上被破坏了。 目前我没有比仅使用 django-nose 测试运行器更好的解决方案。

    【讨论】:

    猜你喜欢
    • 2018-03-12
    • 2017-02-18
    • 2021-05-24
    • 1970-01-01
    • 1970-01-01
    • 2019-01-20
    • 1970-01-01
    • 2012-04-20
    • 1970-01-01
    相关资源
    最近更新 更多