diff --git a/cms/djangoapps/contentstore/tests/test_courseware_index.py b/cms/djangoapps/contentstore/tests/test_courseware_index.py index b6d91b3a04..508f7230c5 100644 --- a/cms/djangoapps/contentstore/tests/test_courseware_index.py +++ b/cms/djangoapps/contentstore/tests/test_courseware_index.py @@ -740,6 +740,12 @@ class TestTaskExecution(SharedModuleStoreTestCase): publish_item=False, ) + @classmethod + def tearDownClass(cls): + SignalHandler.course_published.connect(listen_for_course_publish) + SignalHandler.library_updated.connect(listen_for_library_update) + super(TestTaskExecution, cls).tearDownClass() + def test_task_indexing_course(self): """ Making sure that the receiver correctly fires off the task when invoked by signal """ searcher = SearchEngine.get_search_engine(CoursewareSearchIndexer.INDEX_NAME) diff --git a/cms/djangoapps/contentstore/views/tests/test_course_index.py b/cms/djangoapps/contentstore/views/tests/test_course_index.py index 9dad8412cb..09b16486d0 100644 --- a/cms/djangoapps/contentstore/views/tests/test_course_index.py +++ b/cms/djangoapps/contentstore/views/tests/test_course_index.py @@ -23,9 +23,11 @@ from contentstore.views.course import ( course_outline_initial_state, reindex_course_and_check_access ) +from contentstore.views.course import WAFFLE_NAMESPACE as COURSE_WAFFLE_NAMESPACE from contentstore.views.item import VisibilityState, create_xblock_info from course_action_state.managers import CourseRerunUIStateManager from course_action_state.models import CourseRerunState +from openedx.core.djangoapps.waffle_utils import WaffleSwitchNamespace from student.auth import has_course_author_access from student.roles import CourseStaffRole, GlobalStaff, LibraryUserRole from student.tests.factories import UserFactory @@ -359,6 +361,10 @@ class TestCourseIndexArchived(CourseTestCase): for course in (self.course, self.active_course, self.archived_course): CourseStaffRole(course.id).add_users(self.staff) + # Make sure we've cached data which could change the query counts + # depending on test execution order + WaffleSwitchNamespace(name=COURSE_WAFFLE_NAMESPACE).is_enabled(u'enable_global_staff_optimization') + def check_index_page_with_query_count(self, separate_archived_courses, org, mongo_queries, sql_queries): """ Checks the index page, and ensures the number of database queries is as expected. diff --git a/common/lib/capa/capa/safe_exec/tests/test_lazymod.py b/common/lib/capa/capa/safe_exec/tests/test_lazymod.py index 63b56e7c47..20e131589c 100644 --- a/common/lib/capa/capa/safe_exec/tests/test_lazymod.py +++ b/common/lib/capa/capa/safe_exec/tests/test_lazymod.py @@ -34,15 +34,23 @@ class TestLazyMod(unittest.TestCase): def test_simple(self): # Import some stdlib module that has not been imported before - self.assertNotIn("colorsys", sys.modules) - colorsys = LazyModule("colorsys") + module_name = 'colorsys' + if module_name in sys.modules: + # May have been imported during test discovery, remove it again + del sys.modules[module_name] + assert module_name not in sys.modules + colorsys = LazyModule(module_name) hsv = colorsys.rgb_to_hsv(.3, .4, .2) self.assertEqual(hsv[0], 0.25) def test_dotted(self): # wsgiref is a module with submodules that is not already imported. # Any similar module would do. This test demonstrates that the module - # is not already im - self.assertNotIn("wsgiref.util", sys.modules) - wsgiref_util = LazyModule("wsgiref.util") + # is not already imported + module_name = 'wsgiref.util' + if module_name in sys.modules: + # May have been imported during test discovery, remove it again + del sys.modules[module_name] + assert module_name not in sys.modules + wsgiref_util = LazyModule(module_name) self.assertEqual(wsgiref_util.guess_scheme({}), "http") diff --git a/common/lib/capa/capa/tests/test_html_render.py b/common/lib/capa/capa/tests/test_html_render.py index b5d969cc69..b0c6d88ecf 100644 --- a/common/lib/capa/capa/tests/test_html_render.py +++ b/common/lib/capa/capa/tests/test_html_render.py @@ -7,6 +7,8 @@ import unittest import ddt import mock import os +# Changes formatting of empty elements; import here to avoid test order dependence +import xmodule.modulestore.xml # pylint: disable=unused-import from capa.tests.helpers import test_capa_system, new_loncapa_problem from lxml import etree from openedx.core.djangolib.markup import HTML @@ -303,7 +305,7 @@ class CapaHtmlRenderTest(unittest.TestCase): # Render the HTML the_html = problem.get_html() - self.assertRegexpMatches(the_html, r"