forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
298 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ conf/locale/messages.mo | |
.testids/ | ||
.noseids | ||
nosetests.xml | ||
.cache/ | ||
.coverage | ||
.coverage.* | ||
coverage.xml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
Studio unit test configuration and fixtures. | ||
This module needs to exist because the pytest.ini in the cms package stops | ||
pytest from looking for the conftest.py module in the parent directory when | ||
only running cms tests. | ||
""" | ||
|
||
from __future__ import absolute_import, unicode_literals | ||
|
||
import importlib | ||
import os | ||
import contracts | ||
import pytest | ||
|
||
|
||
def pytest_configure(config): | ||
""" | ||
Do core setup operations from manage.py before collecting tests. | ||
""" | ||
if config.getoption('help'): | ||
return | ||
enable_contracts = os.environ.get('ENABLE_CONTRACTS', False) | ||
if not enable_contracts: | ||
contracts.disable_all() | ||
settings_module = os.environ.get('DJANGO_SETTINGS_MODULE') | ||
startup_module = 'cms.startup' if settings_module.startswith('cms') else 'lms.startup' | ||
startup = importlib.import_module(startup_module) | ||
startup.run() | ||
|
||
|
||
@pytest.fixture(autouse=True, scope='function') | ||
def _django_clear_site_cache(): | ||
""" | ||
pytest-django uses this fixture to automatically clear the Site object | ||
cache by replacing it with a new dictionary. edx-django-sites-extensions | ||
grabs the cache dictionary at startup, and uses that one for all lookups | ||
from then on. Our CacheIsolationMixin class tries to clear the cache by | ||
grabbing the current dictionary from the site models module and clearing | ||
it. Long story short: if you use this all together, neither cache | ||
clearing mechanism actually works. So override this fixture to not mess | ||
with what has been working for us so far. | ||
""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[pytest] | ||
DJANGO_SETTINGS_MODULE = cms.envs.test | ||
addopts = --nomigrations --reuse-db --durations=20 -p no:randomly | ||
norecursedirs = envs | ||
python_classes = | ||
python_files = tests.py test_*.py *_tests.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.conf import settings | ||
|
||
|
||
def pytest_configure(): | ||
""" | ||
Use Django's default settings for tests in common/lib. | ||
""" | ||
settings.configure() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[pytest] | ||
addopts = --nomigrations --reuse-db --durations=20 | ||
norecursedirs = .cache | ||
python_classes = | ||
python_files = tests.py test_*.py tests_*.py *_tests.py __init__.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[pytest] | ||
addopts = -p no:randomly --durations=20 | ||
norecursedirs = .cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
""" | ||
Default unit test configuration and fixtures. | ||
""" | ||
|
||
from __future__ import absolute_import, unicode_literals | ||
|
||
# Import hooks and fixture overrides from the cms package to | ||
# avoid duplicating the implementation | ||
|
||
from cms.conftest import _django_clear_site_cache, pytest_configure # pylint: disable=unused-import |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.