Commit e97b94bd by Ned Batchelder

Merge pull request #8060 from edx/ned/add-supers

Add super() calls to setUp/tearDown that are missing them
parents a57f0d74 78e9445a
...@@ -27,6 +27,7 @@ class CourseCreatorAdminTest(TestCase): ...@@ -27,6 +27,7 @@ class CourseCreatorAdminTest(TestCase):
def setUp(self): def setUp(self):
""" Test case setup """ """ Test case setup """
super(CourseCreatorAdminTest, self).setUp()
self.user = User.objects.create_user('test_user', 'test_user+courses@edx.org', 'foo') self.user = User.objects.create_user('test_user', 'test_user+courses@edx.org', 'foo')
self.table_entry = CourseCreator(user=self.user) self.table_entry = CourseCreator(user=self.user)
self.table_entry.save() self.table_entry.save()
......
...@@ -21,6 +21,7 @@ class CourseCreatorView(TestCase): ...@@ -21,6 +21,7 @@ class CourseCreatorView(TestCase):
def setUp(self): def setUp(self):
""" Test case setup """ """ Test case setup """
super(CourseCreatorView, self).setUp()
self.user = User.objects.create_user('test_user', 'test_user+courses@edx.org', 'foo') self.user = User.objects.create_user('test_user', 'test_user+courses@edx.org', 'foo')
self.admin = User.objects.create_user('Mark', 'admin+courses@edx.org', 'foo') self.admin = User.objects.create_user('Mark', 'admin+courses@edx.org', 'foo')
self.admin.is_staff = True self.admin.is_staff = True
......
...@@ -12,6 +12,7 @@ class TestHandlerUrl(TestCase): ...@@ -12,6 +12,7 @@ class TestHandlerUrl(TestCase):
"""Test the LMS handler_url""" """Test the LMS handler_url"""
def setUp(self): def setUp(self):
super(TestHandlerUrl, self).setUp()
self.block = Mock() self.block = Mock()
def test_trailing_characters(self): def test_trailing_characters(self):
......
...@@ -28,6 +28,7 @@ class ConfigurationModelTests(TestCase): ...@@ -28,6 +28,7 @@ class ConfigurationModelTests(TestCase):
Tests of ConfigurationModel Tests of ConfigurationModel
""" """
def setUp(self): def setUp(self):
super(ConfigurationModelTests, self).setUp()
self.user = User() self.user = User()
self.user.save() self.user.save()
......
...@@ -200,6 +200,7 @@ class ParseRangeHeaderTestCase(unittest.TestCase): ...@@ -200,6 +200,7 @@ class ParseRangeHeaderTestCase(unittest.TestCase):
""" """
def setUp(self): def setUp(self):
super(ParseRangeHeaderTestCase, self).setUp()
self.content_length = 10000 self.content_length = 10000
def test_bytes_unit(self): def test_bytes_unit(self):
......
...@@ -19,6 +19,7 @@ class TestCourseActionStateManagerBase(TestCase): ...@@ -19,6 +19,7 @@ class TestCourseActionStateManagerBase(TestCase):
Base class for testing Course Action State Managers. Base class for testing Course Action State Managers.
""" """
def setUp(self): def setUp(self):
super(TestCourseActionStateManagerBase, self).setUp()
self.course_key = CourseLocator("test_org", "test_course_num", "test_run") self.course_key = CourseLocator("test_org", "test_course_num", "test_run")
......
...@@ -14,6 +14,7 @@ class TestCourseRerunStateManager(TestCase): ...@@ -14,6 +14,7 @@ class TestCourseRerunStateManager(TestCase):
Test class for testing the CourseRerunUIStateManager. Test class for testing the CourseRerunUIStateManager.
""" """
def setUp(self): def setUp(self):
super(TestCourseRerunStateManager, self).setUp()
self.source_course_key = CourseLocator("source_org", "source_course_num", "source_run") self.source_course_key = CourseLocator("source_org", "source_course_num", "source_run")
self.course_key = CourseLocator("test_org", "test_course_num", "test_run") self.course_key = CourseLocator("test_org", "test_course_num", "test_run")
self.created_user = UserFactory() self.created_user = UserFactory()
......
...@@ -22,6 +22,7 @@ class CourseModeModelTest(TestCase): ...@@ -22,6 +22,7 @@ class CourseModeModelTest(TestCase):
""" """
def setUp(self): def setUp(self):
super(CourseModeModelTest, self).setUp()
self.course_key = SlashSeparatedCourseKey('Test', 'TestCourse', 'TestCourseRun') self.course_key = SlashSeparatedCourseKey('Test', 'TestCourse', 'TestCourseRun')
CourseMode.objects.all().delete() CourseMode.objects.all().delete()
......
...@@ -28,6 +28,7 @@ class DarkLangMiddlewareTests(TestCase): ...@@ -28,6 +28,7 @@ class DarkLangMiddlewareTests(TestCase):
Tests of DarkLangMiddleware Tests of DarkLangMiddleware
""" """
def setUp(self): def setUp(self):
super(DarkLangMiddlewareTests, self).setUp()
self.user = User() self.user = User()
self.user.save() self.user.save()
DarkLangConfig( DarkLangConfig(
......
...@@ -12,6 +12,7 @@ class RoleAssignmentTest(TestCase): ...@@ -12,6 +12,7 @@ class RoleAssignmentTest(TestCase):
""" """
def setUp(self): def setUp(self):
super(RoleAssignmentTest, self).setUp()
# Check a staff account because those used to get the Moderator role # Check a staff account because those used to get the Moderator role
self.staff_user = User.objects.create_user( self.staff_user = User.objects.create_user(
"patty", "patty",
......
...@@ -69,6 +69,7 @@ class MakoMiddlewareTest(TestCase): ...@@ -69,6 +69,7 @@ class MakoMiddlewareTest(TestCase):
""" """
def setUp(self): def setUp(self):
super(MakoMiddlewareTest, self).setUp()
self.middleware = edxmako.middleware.MakoMiddleware() self.middleware = edxmako.middleware.MakoMiddleware()
self.user = UserFactory.create() self.user = UserFactory.create()
self.url = "/" self.url = "/"
......
...@@ -201,6 +201,7 @@ class EmbargoMessageUrlApiTests(UrlResetMixin, ModuleStoreTestCase): ...@@ -201,6 +201,7 @@ class EmbargoMessageUrlApiTests(UrlResetMixin, ModuleStoreTestCase):
self.course = CourseFactory.create() self.course = CourseFactory.create()
def tearDown(self): def tearDown(self):
super(EmbargoMessageUrlApiTests, self).tearDown()
cache.clear() cache.clear()
@ddt.data( @ddt.data(
......
...@@ -54,6 +54,7 @@ class IPFilterFormTest(TestCase): ...@@ -54,6 +54,7 @@ class IPFilterFormTest(TestCase):
"""Test form for adding [black|white]list IP addresses""" """Test form for adding [black|white]list IP addresses"""
def tearDown(self): def tearDown(self):
super(IPFilterFormTest, self).tearDown()
# Explicitly clear ConfigurationModel's cache so tests have a clear cache # Explicitly clear ConfigurationModel's cache so tests have a clear cache
# and don't interfere with each other # and don't interfere with each other
cache.clear() cache.clear()
......
...@@ -243,6 +243,7 @@ class CourseAccessRuleHistoryTest(TestCase): ...@@ -243,6 +243,7 @@ class CourseAccessRuleHistoryTest(TestCase):
"""Test course access rule history. """ """Test course access rule history. """
def setUp(self): def setUp(self):
super(CourseAccessRuleHistoryTest, self).setUp()
self.course_key = CourseLocator('edx', 'DemoX', 'Demo_Course') self.course_key = CourseLocator('edx', 'DemoX', 'Demo_Course')
self.restricted_course = RestrictedCourse.objects.create(course_key=self.course_key) self.restricted_course = RestrictedCourse.objects.create(course_key=self.course_key)
self.countries = { self.countries = {
......
...@@ -24,6 +24,7 @@ class EnrollmentTest(TestCase): ...@@ -24,6 +24,7 @@ class EnrollmentTest(TestCase):
COURSE_ID = "some/great/course" COURSE_ID = "some/great/course"
def setUp(self): def setUp(self):
super(EnrollmentTest, self).setUp()
fake_data_api.reset() fake_data_api.reset()
cache.clear() cache.clear()
......
...@@ -25,9 +25,7 @@ class CountryMiddlewareTests(TestCase): ...@@ -25,9 +25,7 @@ class CountryMiddlewareTests(TestCase):
self.request_factory = RequestFactory() self.request_factory = RequestFactory()
self.patcher = patch.object(pygeoip.GeoIP, 'country_code_by_addr', self.mock_country_code_by_addr) self.patcher = patch.object(pygeoip.GeoIP, 'country_code_by_addr', self.mock_country_code_by_addr)
self.patcher.start() self.patcher.start()
self.addCleanup(self.patcher.stop)
def tearDown(self):
self.patcher.stop()
def mock_country_code_by_addr(self, ip_addr): def mock_country_code_by_addr(self, ip_addr):
""" """
......
...@@ -14,6 +14,7 @@ class TestUserPreferenceMiddleware(TestCase): ...@@ -14,6 +14,7 @@ class TestUserPreferenceMiddleware(TestCase):
""" """
def setUp(self): def setUp(self):
super(TestUserPreferenceMiddleware, self).setUp()
self.middleware = LanguagePreferenceMiddleware() self.middleware = LanguagePreferenceMiddleware()
self.session_middleware = SessionMiddleware() self.session_middleware = SessionMiddleware()
self.user = UserFactory.create() self.user = UserFactory.create()
......
...@@ -21,6 +21,7 @@ class MicroSiteSessionCookieTests(TestCase): ...@@ -21,6 +21,7 @@ class MicroSiteSessionCookieTests(TestCase):
""" """
def setUp(self): def setUp(self):
super(MicroSiteSessionCookieTests, self).setUp()
# create a test client # create a test client
self.client = Client() self.client = Client()
......
...@@ -78,6 +78,7 @@ class MonkeyPatchTest(TestCase): ...@@ -78,6 +78,7 @@ class MonkeyPatchTest(TestCase):
""" """
Remember the current state, then reset Remember the current state, then reset
""" """
super(MonkeyPatchTest, self).setUp()
self.was_patched = unpatch() self.was_patched = unpatch()
self.unpatch_all() self.unpatch_all()
self.addCleanup(self.cleanup) self.addCleanup(self.cleanup)
......
...@@ -19,6 +19,7 @@ class PerformanceTrackingTest(TestCase): ...@@ -19,6 +19,7 @@ class PerformanceTrackingTest(TestCase):
""" """
def setUp(self): def setUp(self):
super(PerformanceTrackingTest, self).setUp()
self.request_factory = RequestFactory() self.request_factory = RequestFactory()
self.stream = StringIO() self.stream = StringIO()
self.handler = logging.StreamHandler(self.stream) self.handler = logging.StreamHandler(self.stream)
......
...@@ -15,6 +15,7 @@ class CeleryConfigTest(unittest.TestCase): ...@@ -15,6 +15,7 @@ class CeleryConfigTest(unittest.TestCase):
""" """
Create a django test client Create a django test client
""" """
super(CeleryConfigTest, self).setUp()
self.client = Client() self.client = Client()
self.ping_url = reverse('status.service.celery.ping') self.ping_url = reverse('status.service.celery.ping')
......
...@@ -57,8 +57,10 @@ class TestStatus(TestCase): ...@@ -57,8 +57,10 @@ class TestStatus(TestCase):
Fake course ids, since we don't have to have full django Fake course ids, since we don't have to have full django
settings (common tests run without the lms settings imported) settings (common tests run without the lms settings imported)
""" """
super(TestStatus, self).setUp()
self.full_id = 'edX/full/2012_Fall' self.full_id = 'edX/full/2012_Fall'
self.toy_id = 'edX/toy/2012_Fall' self.toy_id = 'edX/toy/2012_Fall'
self.addCleanup(self.remove_status_file)
def create_status_file(self, contents): def create_status_file(self, contents):
""" """
...@@ -79,9 +81,6 @@ class TestStatus(TestCase): ...@@ -79,9 +81,6 @@ class TestStatus(TestCase):
if os.path.exists(settings.STATUS_MESSAGE_PATH): if os.path.exists(settings.STATUS_MESSAGE_PATH):
os.remove(settings.STATUS_MESSAGE_PATH) os.remove(settings.STATUS_MESSAGE_PATH)
def tearDown(self):
self.remove_status_file()
@ddt.data(*checks) @ddt.data(*checks)
@ddt.unpack @ddt.unpack
def test_get_site_status_msg(self, json_str, exp_none, exp_toy, exp_full): def test_get_site_status_msg(self, json_str, exp_none, exp_toy, exp_full):
......
...@@ -33,10 +33,7 @@ class TestTransferStudents(ModuleStoreTestCase): ...@@ -33,10 +33,7 @@ class TestTransferStudents(ModuleStoreTestCase):
patcher = patch('student.models.tracker') patcher = patch('student.models.tracker')
self.mock_tracker = patcher.start() self.mock_tracker = patcher.start()
self.addCleanup(patcher.stop) self.addCleanup(patcher.stop)
self.addCleanup(UNENROLL_DONE.disconnect, self.assert_unenroll_signal)
def tearDown(self):
"""Disconnects the UNENROLL stub receiver."""
UNENROLL_DONE.disconnect(self.assert_unenroll_signal)
def assert_unenroll_signal(self, skip_refund=False, **kwargs): # pylint: disable=unused-argument def assert_unenroll_signal(self, skip_refund=False, **kwargs): # pylint: disable=unused-argument
""" Signal Receiver stub for testing that the unenroll signal was fired. """ """ Signal Receiver stub for testing that the unenroll signal was fired. """
......
...@@ -20,6 +20,7 @@ class CreatorGroupTest(TestCase): ...@@ -20,6 +20,7 @@ class CreatorGroupTest(TestCase):
def setUp(self): def setUp(self):
""" Test case setup """ """ Test case setup """
super(CreatorGroupTest, self).setUp()
self.user = User.objects.create_user('testuser', 'test+courses@edx.org', 'foo') self.user = User.objects.create_user('testuser', 'test+courses@edx.org', 'foo')
self.admin = User.objects.create_user('Mark', 'admin+courses@edx.org', 'foo') self.admin = User.objects.create_user('Mark', 'admin+courses@edx.org', 'foo')
self.admin.is_staff = True self.admin.is_staff = True
...@@ -138,6 +139,7 @@ class CourseGroupTest(TestCase): ...@@ -138,6 +139,7 @@ class CourseGroupTest(TestCase):
def setUp(self): def setUp(self):
""" Test case setup """ """ Test case setup """
super(CourseGroupTest, self).setUp()
self.global_admin = AdminFactory() self.global_admin = AdminFactory()
self.creator = User.objects.create_user('testcreator', 'testcreator+courses@edx.org', 'foo') self.creator = User.objects.create_user('testcreator', 'testcreator+courses@edx.org', 'foo')
self.staff = User.objects.create_user('teststaff', 'teststaff+courses@edx.org', 'foo') self.staff = User.objects.create_user('teststaff', 'teststaff+courses@edx.org', 'foo')
......
...@@ -49,12 +49,6 @@ class TestStudentDashboardEmailView(ModuleStoreTestCase): ...@@ -49,12 +49,6 @@ class TestStudentDashboardEmailView(ModuleStoreTestCase):
name=self.course.display_name.replace(' ', '_'), name=self.course.display_name.replace(' ', '_'),
) )
def tearDown(self):
"""
Undo all patches.
"""
patch.stopall()
@patch.dict(settings.FEATURES, {'ENABLE_INSTRUCTOR_EMAIL': True, 'REQUIRE_COURSE_EMAIL_AUTH': False}) @patch.dict(settings.FEATURES, {'ENABLE_INSTRUCTOR_EMAIL': True, 'REQUIRE_COURSE_EMAIL_AUTH': False})
def test_email_flag_true(self): def test_email_flag_true(self):
# Assert that the URL for the email view is in the response # Assert that the URL for the email view is in the response
...@@ -97,6 +91,7 @@ class TestStudentDashboardEmailViewXMLBacked(ModuleStoreTestCase): ...@@ -97,6 +91,7 @@ class TestStudentDashboardEmailViewXMLBacked(ModuleStoreTestCase):
MODULESTORE = TEST_DATA_MIXED_TOY_MODULESTORE MODULESTORE = TEST_DATA_MIXED_TOY_MODULESTORE
def setUp(self): def setUp(self):
super(TestStudentDashboardEmailViewXMLBacked, self).setUp()
self.course_name = 'edX/toy/2012_Fall' self.course_name = 'edX/toy/2012_Fall'
# Create student account # Create student account
......
...@@ -19,6 +19,7 @@ class TestChangeName(TestCase): ...@@ -19,6 +19,7 @@ class TestChangeName(TestCase):
Check the change_name view of student. Check the change_name view of student.
""" """
def setUp(self): def setUp(self):
super(TestChangeName, self).setUp()
self.student = UserFactory.create(password='test') self.student = UserFactory.create(password='test')
self.client = Client() self.client = Client()
......
...@@ -45,6 +45,7 @@ class TestCreateAccount(TestCase): ...@@ -45,6 +45,7 @@ class TestCreateAccount(TestCase):
"""Tests for account creation""" """Tests for account creation"""
def setUp(self): def setUp(self):
super(TestCreateAccount, self).setUp()
self.username = "test_user" self.username = "test_user"
self.url = reverse("create_account") self.url = reverse("create_account")
self.request_factory = RequestFactory() self.request_factory = RequestFactory()
...@@ -477,6 +478,7 @@ class TestCreateAccountValidation(TestCase): ...@@ -477,6 +478,7 @@ class TestCreateAccountValidation(TestCase):
class TestCreateCommentsServiceUser(TransactionTestCase): class TestCreateCommentsServiceUser(TransactionTestCase):
def setUp(self): def setUp(self):
super(TestCreateCommentsServiceUser, self).setUp()
self.username = "test_user" self.username = "test_user"
self.url = reverse("create_account") self.url = reverse("create_account")
self.params = { self.params = {
......
...@@ -139,6 +139,7 @@ class ReactivationEmailTests(EmailTestMixin, TestCase): ...@@ -139,6 +139,7 @@ class ReactivationEmailTests(EmailTestMixin, TestCase):
"""Test sending a reactivation email to a user""" """Test sending a reactivation email to a user"""
def setUp(self): def setUp(self):
super(ReactivationEmailTests, self).setUp()
self.user = UserFactory.create() self.user = UserFactory.create()
self.unregisteredUser = UserFactory.create() self.unregisteredUser = UserFactory.create()
self.registration = RegistrationFactory.create(user=self.user) self.registration = RegistrationFactory.create(user=self.user)
...@@ -336,6 +337,7 @@ class EmailChangeRequestTests(EventTestMixin, TestCase): ...@@ -336,6 +337,7 @@ class EmailChangeRequestTests(EventTestMixin, TestCase):
class EmailChangeConfirmationTests(EmailTestMixin, TransactionTestCase): class EmailChangeConfirmationTests(EmailTestMixin, TransactionTestCase):
"""Test that confirmation of email change requests function even in the face of exceptions thrown while sending email""" """Test that confirmation of email change requests function even in the face of exceptions thrown while sending email"""
def setUp(self): def setUp(self):
super(EmailChangeConfirmationTests, self).setUp()
self.user = UserFactory.create() self.user = UserFactory.create()
self.profile = UserProfile.objects.get(user=self.user) self.profile = UserProfile.objects.get(user=self.user)
self.req_factory = RequestFactory() self.req_factory = RequestFactory()
......
...@@ -32,6 +32,7 @@ class LoginTest(TestCase): ...@@ -32,6 +32,7 @@ class LoginTest(TestCase):
''' '''
def setUp(self): def setUp(self):
super(LoginTest, self).setUp()
# Create one user and save it to the database # Create one user and save it to the database
self.user = UserFactory.build(username='test', email='test@edx.org') self.user = UserFactory.build(username='test', email='test@edx.org')
self.user.set_password('test_password') self.user.set_password('test_password')
......
...@@ -8,6 +8,7 @@ from django.core.urlresolvers import reverse ...@@ -8,6 +8,7 @@ from django.core.urlresolvers import reverse
class TestLongUsernameEmail(TestCase): class TestLongUsernameEmail(TestCase):
def setUp(self): def setUp(self):
super(TestLongUsernameEmail, self).setUp()
self.url = reverse('create_account') self.url = reverse('create_account')
self.url_params = { self.url_params = {
'username': 'username', 'username': 'username',
......
...@@ -46,6 +46,7 @@ def fake_microsite_get_value(name, default=None): ...@@ -46,6 +46,7 @@ def fake_microsite_get_value(name, default=None):
class TestMicrosite(TestCase): class TestMicrosite(TestCase):
"""Test for Account Creation from a white labeled Micro-Sites""" """Test for Account Creation from a white labeled Micro-Sites"""
def setUp(self): def setUp(self):
super(TestMicrosite, self).setUp()
self.username = "test_user" self.username = "test_user"
self.url = reverse("create_account") self.url = reverse("create_account")
self.params = { self.params = {
......
...@@ -20,6 +20,7 @@ class RolesTestCase(TestCase): ...@@ -20,6 +20,7 @@ class RolesTestCase(TestCase):
""" """
def setUp(self): def setUp(self):
super(RolesTestCase, self).setUp()
self.course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall') self.course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
self.course_loc = self.course_key.make_usage_key('course', '2012_Fall') self.course_loc = self.course_key.make_usage_key('course', '2012_Fall')
self.anonymous_user = AnonymousUserFactory() self.anonymous_user = AnonymousUserFactory()
...@@ -171,6 +172,7 @@ class RoleCacheTestCase(TestCase): ...@@ -171,6 +172,7 @@ class RoleCacheTestCase(TestCase):
) )
def setUp(self): def setUp(self):
super(RoleCacheTestCase, self).setUp()
self.user = UserFactory() self.user = UserFactory()
@ddt.data(*ROLES) @ddt.data(*ROLES)
......
...@@ -15,6 +15,7 @@ class UserStandingTest(TestCase): ...@@ -15,6 +15,7 @@ class UserStandingTest(TestCase):
"""test suite for user standing view for enabling and disabling accounts""" """test suite for user standing view for enabling and disabling accounts"""
def setUp(self): def setUp(self):
super(UserStandingTest, self).setUp()
# create users # create users
self.bad_user = UserFactory.create( self.bad_user = UserFactory.create(
username='bad_user', username='bad_user',
......
...@@ -17,6 +17,7 @@ class StubEdxNotesServiceTest(unittest.TestCase): ...@@ -17,6 +17,7 @@ class StubEdxNotesServiceTest(unittest.TestCase):
""" """
Start the stub server. Start the stub server.
""" """
super(StubEdxNotesServiceTest, self).setUp()
self.server = StubEdxNotesService() self.server = StubEdxNotesService()
dummy_notes = self._get_dummy_notes(count=2) dummy_notes = self._get_dummy_notes(count=2)
self.server.add_notes(dummy_notes) self.server.add_notes(dummy_notes)
......
...@@ -11,6 +11,7 @@ from terrain.stubs.http import StubHttpService, StubHttpRequestHandler, require_ ...@@ -11,6 +11,7 @@ from terrain.stubs.http import StubHttpService, StubHttpRequestHandler, require_
class StubHttpServiceTest(unittest.TestCase): class StubHttpServiceTest(unittest.TestCase):
def setUp(self): def setUp(self):
super(StubHttpServiceTest, self).setUp()
self.server = StubHttpService() self.server = StubHttpService()
self.addCleanup(self.server.shutdown) self.addCleanup(self.server.shutdown)
self.url = "http://127.0.0.1:{0}/set_config".format(self.server.port) self.url = "http://127.0.0.1:{0}/set_config".format(self.server.port)
...@@ -86,6 +87,7 @@ class RequireParamTest(unittest.TestCase): ...@@ -86,6 +87,7 @@ class RequireParamTest(unittest.TestCase):
""" """
def setUp(self): def setUp(self):
super(RequireParamTest, self).setUp()
self.server = RequireHttpService() self.server = RequireHttpService()
self.addCleanup(self.server.shutdown) self.addCleanup(self.server.shutdown)
self.url = "http://127.0.0.1:{port}".format(port=self.server.port) self.url = "http://127.0.0.1:{port}".format(port=self.server.port)
......
...@@ -16,6 +16,7 @@ class StubLtiServiceTest(unittest.TestCase): ...@@ -16,6 +16,7 @@ class StubLtiServiceTest(unittest.TestCase):
Used for lettuce BDD tests in lms/courseware/features/lti.feature Used for lettuce BDD tests in lms/courseware/features/lti.feature
""" """
def setUp(self): def setUp(self):
super(StubLtiServiceTest, self).setUp()
self.server = StubLtiService() self.server = StubLtiService()
self.uri = 'http://127.0.0.1:{}/'.format(self.server.port) self.uri = 'http://127.0.0.1:{}/'.format(self.server.port)
self.launch_uri = self.uri + 'correct_lti_endpoint' self.launch_uri = self.uri + 'correct_lti_endpoint'
......
...@@ -14,6 +14,7 @@ class StubOraServiceTest(unittest.TestCase): ...@@ -14,6 +14,7 @@ class StubOraServiceTest(unittest.TestCase):
""" """
Start the stub server. Start the stub server.
""" """
super(StubOraServiceTest, self).setUp()
self.server = StubOraService() self.server = StubOraService()
self.addCleanup(self.server.shutdown) self.addCleanup(self.server.shutdown)
......
...@@ -23,6 +23,7 @@ class FakeTimer(object): ...@@ -23,6 +23,7 @@ class FakeTimer(object):
class StubXQueueServiceTest(unittest.TestCase): class StubXQueueServiceTest(unittest.TestCase):
def setUp(self): def setUp(self):
super(StubXQueueServiceTest, self).setUp()
self.server = StubXQueueService() self.server = StubXQueueService()
self.url = "http://127.0.0.1:{0}/xqueue/submit".format(self.server.port) self.url = "http://127.0.0.1:{0}/xqueue/submit".format(self.server.port)
self.addCleanup(self.server.shutdown) self.addCleanup(self.server.shutdown)
......
...@@ -10,6 +10,7 @@ from ..youtube import StubYouTubeService ...@@ -10,6 +10,7 @@ from ..youtube import StubYouTubeService
class StubYouTubeServiceTest(unittest.TestCase): class StubYouTubeServiceTest(unittest.TestCase):
def setUp(self): def setUp(self):
super(StubYouTubeServiceTest, self).setUp()
self.server = StubYouTubeService() self.server = StubYouTubeService()
self.url = "http://127.0.0.1:{0}/".format(self.server.port) self.url = "http://127.0.0.1:{0}/".format(self.server.port)
self.server.config['time_to_response'] = 0.0 self.server.config['time_to_response'] = 0.0
......
...@@ -7,6 +7,7 @@ from track.backends.django import DjangoBackend, TrackingLog ...@@ -7,6 +7,7 @@ from track.backends.django import DjangoBackend, TrackingLog
class TestDjangoBackend(TestCase): class TestDjangoBackend(TestCase):
def setUp(self): def setUp(self):
super(TestDjangoBackend, self).setUp()
self.backend = DjangoBackend() self.backend = DjangoBackend()
def test_django_backend(self): def test_django_backend(self):
......
...@@ -11,7 +11,7 @@ from track.backends.logger import LoggerBackend ...@@ -11,7 +11,7 @@ from track.backends.logger import LoggerBackend
class TestLoggerBackend(TestCase): class TestLoggerBackend(TestCase):
def setUp(self): def setUp(self):
super(TestLoggerBackend, self).setUp()
self.handler = MockLoggingHandler() self.handler = MockLoggingHandler()
self.handler.setLevel(logging.INFO) self.handler.setLevel(logging.INFO)
......
...@@ -9,9 +9,10 @@ from track.backends.mongodb import MongoBackend ...@@ -9,9 +9,10 @@ from track.backends.mongodb import MongoBackend
class TestMongoBackend(TestCase): class TestMongoBackend(TestCase):
def setUp(self): def setUp(self):
super(TestMongoBackend, self).setUp()
self.mongo_patcher = patch('track.backends.mongodb.MongoClient') self.mongo_patcher = patch('track.backends.mongodb.MongoClient')
self.addCleanup(self.mongo_patcher.stop)
self.mongo_patcher.start() self.mongo_patcher.start()
self.addCleanup(self.mongo_patcher.stop)
self.backend = MongoBackend() self.backend = MongoBackend()
......
...@@ -14,6 +14,7 @@ from track.middleware import TrackMiddleware ...@@ -14,6 +14,7 @@ from track.middleware import TrackMiddleware
class TrackMiddlewareTestCase(TestCase): class TrackMiddlewareTestCase(TestCase):
def setUp(self): def setUp(self):
super(TrackMiddlewareTestCase, self).setUp()
self.track_middleware = TrackMiddleware() self.track_middleware = TrackMiddleware()
self.request_factory = RequestFactory() self.request_factory = RequestFactory()
......
...@@ -29,6 +29,7 @@ class TestTrackerInstantiation(TestCase): ...@@ -29,6 +29,7 @@ class TestTrackerInstantiation(TestCase):
"""Test that a helper function can instantiate backends from their name.""" """Test that a helper function can instantiate backends from their name."""
def setUp(self): def setUp(self):
# pylint: disable=protected-access # pylint: disable=protected-access
super(TestTrackerInstantiation, self).setUp()
self.get_backend = tracker._instantiate_backend_from_name self.get_backend = tracker._instantiate_backend_from_name
def test_instatiate_backend(self): def test_instatiate_backend(self):
......
...@@ -30,6 +30,7 @@ class DisableRateLimitTest(TestCase): ...@@ -30,6 +30,7 @@ class DisableRateLimitTest(TestCase):
"""Check that we can disable rate limiting for perf testing. """ """Check that we can disable rate limiting for perf testing. """
def setUp(self): def setUp(self):
super(DisableRateLimitTest, self).setUp()
cache.clear() cache.clear()
self.view = FakeApiView() self.view = FakeApiView()
......
...@@ -52,6 +52,7 @@ class FilenameGeneratorTestCase(TestCase): ...@@ -52,6 +52,7 @@ class FilenameGeneratorTestCase(TestCase):
NOW = datetime.strptime('1974-06-22T01:02:03', '%Y-%m-%dT%H:%M:%S').replace(tzinfo=UTC()) NOW = datetime.strptime('1974-06-22T01:02:03', '%Y-%m-%dT%H:%M:%S').replace(tzinfo=UTC())
def setUp(self): def setUp(self):
super(FilenameGeneratorTestCase, self).setUp()
datetime_patcher = patch.object( datetime_patcher = patch.object(
util.file, 'datetime', util.file, 'datetime',
Mock(wraps=datetime) Mock(wraps=datetime)
...@@ -84,6 +85,7 @@ class StoreUploadedFileTestCase(TestCase): ...@@ -84,6 +85,7 @@ class StoreUploadedFileTestCase(TestCase):
""" """
def setUp(self): def setUp(self):
super(StoreUploadedFileTestCase, self).setUp()
self.request = Mock(spec=HttpRequest) self.request = Mock(spec=HttpRequest)
self.file_content = "test file content" self.file_content = "test file content"
self.request.FILES = {"uploaded_file": SimpleUploadedFile("tempfile.csv", self.file_content)} self.request.FILES = {"uploaded_file": SimpleUploadedFile("tempfile.csv", self.file_content)}
...@@ -92,6 +94,7 @@ class StoreUploadedFileTestCase(TestCase): ...@@ -92,6 +94,7 @@ class StoreUploadedFileTestCase(TestCase):
self.default_max_size = 2000000 self.default_max_size = 2000000
def tearDown(self): def tearDown(self):
super(StoreUploadedFileTestCase, self).tearDown()
if self.file_storage and self.stored_file_name: if self.file_storage and self.stored_file_name:
self.file_storage.delete(self.stored_file_name) self.file_storage.delete(self.stored_file_name)
......
...@@ -17,6 +17,7 @@ class MemcacheTest(TestCase): ...@@ -17,6 +17,7 @@ class MemcacheTest(TestCase):
[129, 500, 2 ** 8 - 1, 2 ** 8 + 1, 2 ** 16 - 1]) [129, 500, 2 ** 8 - 1, 2 ** 8 + 1, 2 ** 16 - 1])
def setUp(self): def setUp(self):
super(MemcacheTest, self).setUp()
self.cache = get_cache('default') self.cache = get_cache('default')
def test_safe_key(self): def test_safe_key(self):
......
...@@ -12,10 +12,12 @@ from util.request import course_id_from_url, safe_get_host ...@@ -12,10 +12,12 @@ from util.request import course_id_from_url, safe_get_host
class ResponseTestCase(unittest.TestCase): class ResponseTestCase(unittest.TestCase):
""" Tests for response-related utility functions """ """ Tests for response-related utility functions """
def setUp(self): def setUp(self):
super(ResponseTestCase, self).setUp()
self.old_site_name = settings.SITE_NAME self.old_site_name = settings.SITE_NAME
self.old_allowed_hosts = settings.ALLOWED_HOSTS self.old_allowed_hosts = settings.ALLOWED_HOSTS
def tearDown(self): def tearDown(self):
super(ResponseTestCase, self).tearDown()
settings.SITE_NAME = self.old_site_name settings.SITE_NAME = self.old_site_name
settings.ALLOWED_HOSTS = self.old_allowed_hosts settings.ALLOWED_HOSTS = self.old_allowed_hosts
......
...@@ -21,6 +21,7 @@ from student.tests.test_microsite import fake_microsite_get_value ...@@ -21,6 +21,7 @@ from student.tests.test_microsite import fake_microsite_get_value
class SubmitFeedbackTest(TestCase): class SubmitFeedbackTest(TestCase):
def setUp(self): def setUp(self):
"""Set up data for the test case""" """Set up data for the test case"""
super(SubmitFeedbackTest, self).setUp()
self._request_factory = RequestFactory() self._request_factory = RequestFactory()
self._anon_user = AnonymousUser() self._anon_user = AnonymousUser()
self._auth_user = UserFactory.create( self._auth_user = UserFactory.create(
......
...@@ -19,6 +19,7 @@ class UserServiceTestCase(TestCase): ...@@ -19,6 +19,7 @@ class UserServiceTestCase(TestCase):
Tests for the DjangoXBlockUserService. Tests for the DjangoXBlockUserService.
""" """
def setUp(self): def setUp(self):
super(UserServiceTestCase, self).setUp()
self.user = UserFactory(username="tester", email="test@tester.com") self.user = UserFactory(username="tester", email="test@tester.com")
self.user.profile.name = "Test Tester" self.user.profile.name = "Test Tester"
self.anon_user = AnonymousUserFactory() self.anon_user = AnonymousUserFactory()
......
...@@ -28,6 +28,7 @@ class ModuleIsolation(object): ...@@ -28,6 +28,7 @@ class ModuleIsolation(object):
class TestLazyMod(unittest.TestCase): class TestLazyMod(unittest.TestCase):
def setUp(self): def setUp(self):
super(TestLazyMod, self).setUp()
# Each test will remove modules that it imported. # Each test will remove modules that it imported.
self.addCleanup(ModuleIsolation().clean_up) self.addCleanup(ModuleIsolation().clean_up)
......
...@@ -49,6 +49,7 @@ class CoursewareSearchTest(UniqueCourseTest): ...@@ -49,6 +49,7 @@ class CoursewareSearchTest(UniqueCourseTest):
# create test file in which index for this test will live # create test file in which index for this test will live
with open(self.TEST_INDEX_FILENAME, "w+") as index_file: with open(self.TEST_INDEX_FILENAME, "w+") as index_file:
json.dump({}, index_file) json.dump({}, index_file)
self.addCleanup(os.remove, self.TEST_INDEX_FILENAME)
super(CoursewareSearchTest, self).setUp() super(CoursewareSearchTest, self).setUp()
self.courseware_search_page = CoursewareSearchPage(self.browser, self.course_id) self.courseware_search_page = CoursewareSearchPage(self.browser, self.course_id)
...@@ -77,9 +78,6 @@ class CoursewareSearchTest(UniqueCourseTest): ...@@ -77,9 +78,6 @@ class CoursewareSearchTest(UniqueCourseTest):
) )
).install() ).install()
def tearDown(self):
os.remove(self.TEST_INDEX_FILENAME)
def _auto_auth(self, username, email, staff): def _auto_auth(self, username, email, staff):
""" """
Logout and login with given credentials. Logout and login with given credentials.
......
...@@ -95,10 +95,9 @@ class EdxNotesTestMixin(UniqueCourseTest): ...@@ -95,10 +95,9 @@ class EdxNotesTestMixin(UniqueCourseTest):
), ),
)).install() )).install()
AutoAuthPage(self.browser, username=self.username, email=self.email, course_id=self.course_id).visit() self.addCleanup(self.edxnotes_fixture.cleanup)
def tearDown(self): AutoAuthPage(self.browser, username=self.username, email=self.email, course_id=self.course_id).visit()
self.edxnotes_fixture.cleanup()
def _add_notes(self): def _add_notes(self):
xblocks = self.course_fixture.get_nested_xblocks(category="html") xblocks = self.course_fixture.get_nested_xblocks(category="html")
......
...@@ -118,13 +118,6 @@ class TestCoachDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase): ...@@ -118,13 +118,6 @@ class TestCoachDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase):
from django.core import mail from django.core import mail
return mail.outbox return mail.outbox
def tearDown(self):
"""
Undo patches.
"""
super(TestCoachDashboard, self).tearDown()
patch.stopall()
def test_not_a_coach(self): def test_not_a_coach(self):
""" """
User is not a coach, should get Forbidden response. User is not a coach, should get Forbidden response.
......
...@@ -40,12 +40,6 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase): ...@@ -40,12 +40,6 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase):
# URL for instructor dash # URL for instructor dash
self.url = reverse('instructor_dashboard', kwargs={'course_id': self.course.id.to_deprecated_string()}) self.url = reverse('instructor_dashboard', kwargs={'course_id': self.course.id.to_deprecated_string()})
def tearDown(self):
"""
Undo patches.
"""
patch.stopall()
def get_dashboard_enrollment_message(self): def get_dashboard_enrollment_message(self):
""" """
Returns expected dashboard enrollment message with link to Insights. Returns expected dashboard enrollment message with link to Insights.
......
...@@ -13,6 +13,7 @@ class TestCourseTagAPI(TestCase): ...@@ -13,6 +13,7 @@ class TestCourseTagAPI(TestCase):
Test the user service Test the user service
""" """
def setUp(self): def setUp(self):
super(TestCourseTagAPI, self).setUp()
self.user = UserFactory.create() self.user = UserFactory.create()
self.course_id = SlashSeparatedCourseKey('test_org', 'test_course_number', 'test_run') self.course_id = SlashSeparatedCourseKey('test_org', 'test_course_number', 'test_run')
self.test_key = 'test_key' self.test_key = 'test_key'
......
...@@ -134,6 +134,7 @@ class FormDescriptionTest(TestCase): ...@@ -134,6 +134,7 @@ class FormDescriptionTest(TestCase):
class StudentViewShimTest(TestCase): class StudentViewShimTest(TestCase):
"Tests of the student view shim." "Tests of the student view shim."
def setUp(self): def setUp(self):
super(StudentViewShimTest, self).setUp()
self.captured_request = None self.captured_request = None
def test_strip_enrollment_action(self): def test_strip_enrollment_action(self):
......
...@@ -16,6 +16,7 @@ class TagsMiddlewareTest(TestCase): ...@@ -16,6 +16,7 @@ class TagsMiddlewareTest(TestCase):
Test the UserTagsEventContextMiddleware Test the UserTagsEventContextMiddleware
""" """
def setUp(self): def setUp(self):
super(TagsMiddlewareTest, self).setUp()
self.middleware = UserTagsEventContextMiddleware() self.middleware = UserTagsEventContextMiddleware()
self.user = UserFactory.create() self.user = UserFactory.create()
self.other_user = UserFactory.create() self.other_user = UserFactory.create()
......
...@@ -42,13 +42,11 @@ class TestRandomUserPartitionScheme(PartitionTestCase): ...@@ -42,13 +42,11 @@ class TestRandomUserPartitionScheme(PartitionTestCase):
'openedx.core.djangoapps.user_api.partition_schemes.course_tag_api', course_tag_api 'openedx.core.djangoapps.user_api.partition_schemes.course_tag_api', course_tag_api
) )
self.user_service_patcher.start() self.user_service_patcher.start()
self.addCleanup(self.user_service_patcher.stop)
# Create a test user # Create a test user
self.user = UserFactory.create() self.user = UserFactory.create()
def tearDown(self):
self.user_service_patcher.stop()
def test_get_group_for_user(self): def test_get_group_for_user(self):
# get a group assigned to the user # get a group assigned to the user
group1_id = RandomUserPartitionScheme.get_group_for_user(self.MOCK_COURSE_ID, self.user, self.user_partition) group1_id = RandomUserPartitionScheme.get_group_for_user(self.MOCK_COURSE_ID, self.user, self.user_partition)
......
...@@ -9,6 +9,7 @@ REPO_DIR = os.getcwd() ...@@ -9,6 +9,7 @@ REPO_DIR = os.getcwd()
class TestPaverBokChoyCmd(unittest.TestCase): class TestPaverBokChoyCmd(unittest.TestCase):
def setUp(self): def setUp(self):
super(TestPaverBokChoyCmd, self).setUp()
self.request = BokChoyTestSuite('') self.request = BokChoyTestSuite('')
def _expected_command(self, expected_text_append, expected_default_store=None): def _expected_command(self, expected_text_append, expected_default_store=None):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment