运行完整套件

时间:2017-08-15 08:23:47

标签: python django unit-testing

我必须改变场景背后具有深刻逻辑的.clean() 由于它与我的功能没有直接关系,所以我决定嘲笑它并削减复杂的逻辑。然后我可以使用mommy.make来完成测试对象。<​​br/>

这是我的代码。
https://gist.github.com/elcolie/cfeadfbb29996823abfb998447cfe822

如果我单独运行它就可以了。但是当跑完整套房时失败。

我遵循了这些:
why would a django test fail only when the full test suite is run?
Django unit tests failing when run with other test cases
但是不起作用。

我的错误: 2最后一个测试用例失败

Failure
Traceback (most recent call last):
  File "/Users/el/.pyenv/versions/3.6.0/lib/python3.6/unittest/mock.py", line 1179, in patched
    return func(*args, **keywargs)
  File "/Users/el/Code/eneos-pos-web/eneos/apps/mail_logs/mail_data_tests.py", line 194, in test_user_change_status_13July_query_all_false
    self.assertDictEqual(expected_obj, summary)
AssertionError: {'tod[71 chars] 0, 'today_active_email_true': 0, 'today_active_email_none': 1} != {'tod[71 chars] 0, 'today_active_email_true': 0, 'today_active_email_none': 0}
  {'today_active_email': 1,
   'today_active_email_false': 0,
-  'today_active_email_none': 1,
?                             ^

+  'today_active_email_none': 0,
?                             ^

   'today_active_email_true': 0,
   'today_all_orders': 1}


Failure
Traceback (most recent call last):
  File "/Users/el/.pyenv/versions/3.6.0/lib/python3.6/unittest/mock.py", line 1179, in patched
    return func(*args, **keywargs)
  File "/Users/el/Code/eneos-pos-web/eneos/apps/mail_logs/mail_data_tests.py", line 231, in test_user_change_status_16July
    self.assertDictEqual(expected_obj, summary)
AssertionError: {'today_active_email': 1, 'today_active_email_fals[84 chars]': 1} != {'today_all_orders': 1, 'today_active_email': 1, '[84 chars]': 0}
  {'today_active_email': 1,
   'today_active_email_false': 0,
-  'today_active_email_none': 1,
?                             ^

+  'today_active_email_none': 0,
?                             ^

   'today_active_email_true': 0,
   'today_all_orders': 1}

1 个答案:

答案 0 :(得分:0)

我确信程序逻辑与序列id没有限制 但是,要使数据库恢复到原始状态,就像个别运行一样 我使用以下配置。

class MailLogFixture(TransactionTestCase):
    reset_sequences = True

它有效