Closed
Bug 1056870
Opened 10 years ago
Closed 9 years ago
Fix tests to always use amo.tests.TestCase
Categories
(addons.mozilla.org Graveyard :: Code Quality, defect, P4)
addons.mozilla.org Graveyard
Code Quality
Tracking
(Not tracked)
RESOLVED
FIXED
2015-09-03
People
(Reporter: mat, Assigned: magopian)
Details
(Whiteboard: [qa-])
Some AMO tests are using unittest.TestCase or django.test.TestCase. This is dangerous because then the cache won't be cleared before running the affected tests (test_utils.TestCase does that, and amo.tests.TestCase inherits from it). There are probably other incentives for switching all tests to amo.tests.TestCase, but just this one should be enough :) In particular, apps/amo/tests/test_send_mail.py tests pass by accident because the FakeEmail messages bodies are not different between tests...
Comment 1•9 years ago
|
||
The only remaining instance is from apps/translations/: * apps/translations/tests/test_models.py:class TranslationMultiDbTests(TransactionTestCase):
Assignee | ||
Comment 2•9 years ago
|
||
From my quick investigations, it seems there's in fact two testcases that don't inherit from amo.tests.BaseTestCase: <class 'olympia.apps.tags.tests.test_helpers.TestHelpers'> <class 'olympia.apps.translations.tests.test_models.TranslationMultiDbTests'> The script I used to get that: some hackery using pytest's test collection (put that in your base conftest.py): @pytest.fixture(scope="session", autouse=True) def callattr_ahead_of_alltests(request): from amo.tests import BaseTestCase not_amo_testcase = set() session = request.node for item in session.items: cls = item.getparent(pytest.Class) if not cls: continue if BaseTestCase not in cls.cls.__mro__: not_amo_testcase.add(cls.cls) print(not_amo_testcase) import ipdb; ipdb.set_trace()
Assignee | ||
Comment 3•9 years ago
|
||
PR: https://github.com/mozilla/olympia/pull/690
Comment 4•9 years ago
|
||
Commits pushed to master at https://github.com/mozilla/olympia https://github.com/mozilla/olympia/commit/93248e5757ea1e6b6535ef089a228c909f01f66f Do a proper _pre_setup and _post_teardown for all the tests (bug 1056870) https://github.com/mozilla/olympia/commit/ac80230eb2aef098e069cb2659e299a71b5e305b Merge pull request #690 from magopian/1056870-pre_setup-post_teardown-all-the-things Do a proper _pre_setup and _post_teardown for all the tests (bug 1056870)
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → mathieu
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Whiteboard: [qa-]
Target Milestone: --- → 2015-09-03
Updated•8 years ago
|
Product: addons.mozilla.org → addons.mozilla.org Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•