diff --git a/lms/djangoapps/instructor/tests/test_api.py b/lms/djangoapps/instructor/tests/test_api.py index 00b0fc56b05f..0158ce0ec8c6 100644 --- a/lms/djangoapps/instructor/tests/test_api.py +++ b/lms/djangoapps/instructor/tests/test_api.py @@ -920,15 +920,16 @@ def test_users_created_and_enrolled_successfully_if_others_fail(self): manual_enrollments = ManualEnrollmentAudit.objects.all() assert manual_enrollments.count() == 2 - @patch('lms.djangoapps.instructor.views.api', 'generate_random_string', - Mock(side_effect=['first', 'first', 'second'])) def test_generate_unique_password_no_reuse(self): """ generate_unique_password should generate a unique password string that hasn't been generated before. """ - generated_password = ['first'] - password = generate_unique_password(generated_password, 12) - assert password != 'first' + with patch('lms.djangoapps.instructor.views.api.generate_random_string') as mock: + mock.side_effect = ['first', 'first', 'second'] + + generated_password = ['first'] + password = generate_unique_password(generated_password, 12) + assert password != 'first' @patch.dict(settings.FEATURES, {'ALLOW_AUTOMATED_SIGNUPS': False}) def test_allow_automated_signups_flag_not_set(self):