python - Why mock model method failed when run full suite -
i have change .clean()
has deep logic behind scene.
since not directly related feature decided mock out , cut complicate logic. can use mommy.make
fulfill testing objects.
here code.
https://gist.github.com/elcolie/cfeadfbb29996823abfb998447cfe822
if run them individually works. fail when run full suite.
i had follow these:
why django test fail when full test suite run?
django unit tests failing when run other test cases
not work.
my errors: 2 last test cases fail
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}
i sure program logic has not bounded sequence id.
however, keep database original state individual runs.
use following config.
class maillogfixture(transactiontestcase): reset_sequences = true
and works
Comments
Post a Comment