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 |
|---|---|---|
| .tx | Loading commit data... | |
| cms | Loading commit data... | |
| common | Loading commit data... | |
| conf/locale | Loading commit data... | |
| docs | Loading commit data... | |
| lms | Loading commit data... | |
| openedx | Loading commit data... | |
| pavelib | Loading commit data... | |
| requirements | Loading commit data... | |
| scripts | Loading commit data... | |
| test_root | Loading commit data... | |
| vendor_extra/tinymce | Loading commit data... | |
| .gitattributes | Loading commit data... | |
| .gitignore | Loading commit data... | |
| .jshintrc | Loading commit data... | |
| .ruby-gemset | Loading commit data... | |
| .ruby-version | Loading commit data... | |
| AUTHORS | Loading commit data... | |
| Brewfile | Loading commit data... | |
| CHANGELOG.rst | Loading commit data... | |
| CONTRIBUTING.rst | Loading commit data... | |
| Gemfile | Loading commit data... | |
| Gemfile.lock | Loading commit data... | |
| LICENSE | Loading commit data... | |
| README.md | Loading commit data... | |
| manage.py | Loading commit data... | |
| mongo_indexes.md | Loading commit data... | |
| package.json | Loading commit data... | |
| pavement.py | Loading commit data... | |
| pylintrc | Loading commit data... | |
| setup.cfg | Loading commit data... | |
| setup.py | Loading commit data... |