The existing pattern of using `override_settings(MODULESTORE=...)` prevented
us from having more than one layer of subclassing in modulestore tests.
In a structure like:
@override_settings(MODULESTORE=store_a)
class BaseTestCase(ModuleStoreTestCase):
def setUp(self):
# use store
@override_settings(MODULESTORE=store_b)
class ChildTestCase(BaseTestCase):
def setUp(self):
# use store
In this case, the store actions performed in `BaseTestCase` on behalf of
`ChildTestCase` would still use `store_a`, even though the `ChildTestCase`
had specified to use `store_b`. This is because the `override_settings`
decorator would be the innermost wrapper around the `BaseTestCase.setUp` method,
no matter what `ChildTestCase` does.
To remedy this, we move the call to `override_settings` into the
`ModuleStoreTestCase.setUp` method, and use a cleanup to remove the override.
Subclasses can just defined the `MODULESTORE` class attribute to specify which
modulestore to use _for the entire `setUp` chain_.
[PLAT-419]
| Name |
Last commit
|
Last update |
|---|---|---|
| .. | ||
| tests | Loading commit data... | |
| __init__.py | Loading commit data... | |
| access.py | Loading commit data... | |
| assets.py | Loading commit data... | |
| checklist.py | Loading commit data... | |
| component.py | Loading commit data... | |
| course.py | Loading commit data... | |
| dev.py | Loading commit data... | |
| entrance_exam.py | Loading commit data... | |
| error.py | Loading commit data... | |
| export_git.py | Loading commit data... | |
| helpers.py | Loading commit data... | |
| import_export.py | Loading commit data... | |
| item.py | Loading commit data... | |
| library.py | Loading commit data... | |
| preview.py | Loading commit data... | |
| public.py | Loading commit data... | |
| session_kv_store.py | Loading commit data... | |
| tabs.py | Loading commit data... | |
| transcripts_ajax.py | Loading commit data... | |
| user.py | Loading commit data... | |
| videos.py | Loading commit data... | |
| xblock.py | Loading commit data... |