Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion common/djangoapps/util/testing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys

from django.conf import settings
from django.core.urlresolvers import clear_url_caches
from django.core.urlresolvers import clear_url_caches, resolve


class UrlResetMixin(object):
Expand All @@ -27,6 +27,9 @@ def _reset_urls(self, urlconf=None):
reload(sys.modules[urlconf])
clear_url_caches()

# Resolve a URL so that the new urlconf gets loaded
resolve('/')

def setUp(self):
"""Reset django default urlconf before tests and after tests"""
super(UrlResetMixin, self).setUp()
Expand Down
12 changes: 4 additions & 8 deletions lms/djangoapps/django_comment_client/base/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging

from django.conf import settings
from django.test.utils import override_settings
from django.test.client import Client
from django.contrib.auth.models import User
Expand All @@ -21,16 +20,13 @@
@override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE)
@patch('comment_client.utils.requests.request')
class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase):

@patch.dict("django.conf.settings.MITX_FEATURES", {"ENABLE_DISCUSSION_SERVICE": True})
def setUp(self):

# This feature affects the contents of urls.py, so we change
# it before the call to super.setUp() which reloads urls.py (because
# Patching the ENABLE_DISCUSSION_SERVICE value affects the contents of urls.py,
# so we need to call super.setUp() which reloads urls.py (because
# of the UrlResetMixin)

# This setting is cleaned up at the end of the test by @override_settings, which
# restores all of the old settings
settings.MITX_FEATURES['ENABLE_DISCUSSION_SERVICE'] = True

super(ViewsTestCase, self).setUp()

# create a course
Expand Down