From c124fb343ba2b4bac97c48affbf9f5dd41661980 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 2 Jun 2016 13:30:10 -0400 Subject: [PATCH] Make test_favicon tests work independently --- .../courseware/tests/test_favicon.py | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lms/djangoapps/courseware/tests/test_favicon.py b/lms/djangoapps/courseware/tests/test_favicon.py index 243b689d84..6e57e73d2f 100644 --- a/lms/djangoapps/courseware/tests/test_favicon.py +++ b/lms/djangoapps/courseware/tests/test_favicon.py @@ -9,12 +9,14 @@ from nose.plugins.attrib import attr import sys +from util.testing import UrlResetMixin + @attr('shard_1') -class FaviconTestCase(TestCase): - - def setUp(self): - super(FaviconTestCase, self).setUp() +class FaviconTestCase(UrlResetMixin, TestCase): + """ + Tests of the courseware favicon. + """ def test_favicon_redirect(self): resp = self.client.get("/favicon.ico") @@ -27,15 +29,7 @@ class FaviconTestCase(TestCase): @override_settings(FAVICON_PATH="images/foo.ico") def test_favicon_redirect_with_favicon_path_setting(self): - - # for some reason I had to put this inline rather than just using - # the UrlResetMixin - - urlconf = settings.ROOT_URLCONF - if urlconf in sys.modules: - reload(sys.modules[urlconf]) - clear_url_caches() - resolve("/") + self.reset_urls() resp = self.client.get("/favicon.ico") self.assertEqual(resp.status_code, 301) @@ -46,14 +40,16 @@ class FaviconTestCase(TestCase): ) @patch.dict("django.conf.settings.FEATURES", {"USE_CUSTOM_THEME": True}) + @override_settings(FAVICON_PATH="images/bar_fav.ico") @override_settings(THEME_NAME="bar") def test_favicon_redirect_with_theme(self): self.assertEqual(settings.FEATURES["USE_CUSTOM_THEME"], True) + self.reset_urls() resp = self.client.get("/favicon.ico") self.assertEqual(resp.status_code, 301) self.assertRedirects( resp, - "/static/images/foo.ico", + "/static/images/bar_fav.ico", status_code=301, target_status_code=404 # @@@ how to avoid 404? )