Commit e77211b7 by Sarina Canelake

Run pep8 on all files, and fix uncovered errors

parent bd090a6e
...@@ -24,6 +24,7 @@ from ..tests.helpers import ( ...@@ -24,6 +24,7 @@ from ..tests.helpers import (
CohortFactory, CourseCohortFactory, CourseCohortSettingsFactory CohortFactory, CourseCohortFactory, CourseCohortSettingsFactory
) )
@patch("openedx.core.djangoapps.course_groups.cohorts.tracker") @patch("openedx.core.djangoapps.course_groups.cohorts.tracker")
class TestCohortSignals(TestCase): class TestCohortSignals(TestCase):
def setUp(self): def setUp(self):
...@@ -405,7 +406,6 @@ class TestCohorts(ModuleStoreTestCase): ...@@ -405,7 +406,6 @@ class TestCohorts(ModuleStoreTestCase):
"No groups->default cohort for user2" "No groups->default cohort for user2"
) )
def test_auto_cohorting_randomization(self): def test_auto_cohorting_randomization(self):
""" """
Make sure cohorts.get_cohort() randomizes properly. Make sure cohorts.get_cohort() randomizes properly.
......
...@@ -204,7 +204,7 @@ class TestPreferenceAPI(TestCase): ...@@ -204,7 +204,7 @@ class TestPreferenceAPI(TestCase):
too_long_key = "x" * 256 too_long_key = "x" * 256
with self.assertRaises(PreferenceValidationError) as context_manager: with self.assertRaises(PreferenceValidationError) as context_manager:
update_user_preferences(self.user, { too_long_key: "new_value"}) update_user_preferences(self.user, {too_long_key: "new_value"})
errors = context_manager.exception.preference_errors errors = context_manager.exception.preference_errors
self.assertEqual(len(errors.keys()), 1) self.assertEqual(len(errors.keys()), 1)
self.assertEqual( self.assertEqual(
...@@ -217,7 +217,7 @@ class TestPreferenceAPI(TestCase): ...@@ -217,7 +217,7 @@ class TestPreferenceAPI(TestCase):
for empty_value in ("", " "): for empty_value in ("", " "):
with self.assertRaises(PreferenceValidationError) as context_manager: with self.assertRaises(PreferenceValidationError) as context_manager:
update_user_preferences(self.user, { self.test_preference_key: empty_value}) update_user_preferences(self.user, {self.test_preference_key: empty_value})
errors = context_manager.exception.preference_errors errors = context_manager.exception.preference_errors
self.assertEqual(len(errors.keys()), 1) self.assertEqual(len(errors.keys()), 1)
self.assertEqual( self.assertEqual(
...@@ -230,7 +230,7 @@ class TestPreferenceAPI(TestCase): ...@@ -230,7 +230,7 @@ class TestPreferenceAPI(TestCase):
user_preference_save.side_effect = [Exception, None] user_preference_save.side_effect = [Exception, None]
with self.assertRaises(PreferenceUpdateError) as context_manager: with self.assertRaises(PreferenceUpdateError) as context_manager:
update_user_preferences(self.user, { self.test_preference_key: "new_value"}) update_user_preferences(self.user, {self.test_preference_key: "new_value"})
self.assertEqual( self.assertEqual(
context_manager.exception.developer_message, context_manager.exception.developer_message,
u"Save failed for user preference 'test_key' with value 'new_value': " u"Save failed for user preference 'test_key' with value 'new_value': "
......
...@@ -204,5 +204,5 @@ class PreferencesDetailView(APIView): ...@@ -204,5 +204,5 @@ class PreferencesDetailView(APIView):
if not preference_existed: if not preference_existed:
return Response(status=status.HTTP_404_NOT_FOUND) return Response(status=status.HTTP_404_NOT_FOUND)
return Response(status=status.HTTP_204_NO_CONTENT) return Response(status=status.HTTP_204_NO_CONTENT)
...@@ -1686,7 +1686,6 @@ class TestFacebookRegistrationView( ...@@ -1686,7 +1686,6 @@ class TestFacebookRegistrationView(
self._verify_user_existence(user_exists=False, social_link_exists=False) self._verify_user_existence(user_exists=False, social_link_exists=False)
@skipUnless(settings.FEATURES.get("ENABLE_THIRD_PARTY_AUTH"), "third party auth not enabled") @skipUnless(settings.FEATURES.get("ENABLE_THIRD_PARTY_AUTH"), "third party auth not enabled")
class TestGoogleRegistrationView( class TestGoogleRegistrationView(
ThirdPartyRegistrationTestMixin, ThirdPartyOAuthTestMixinGoogle, TransactionTestCase ThirdPartyRegistrationTestMixin, ThirdPartyOAuthTestMixinGoogle, TransactionTestCase
......
...@@ -382,8 +382,9 @@ class RegistrationView(APIView): ...@@ -382,8 +382,9 @@ class RegistrationView(APIView):
# Translators: These instructions appear on the registration form, immediately # Translators: These instructions appear on the registration form, immediately
# below a field meant to hold the user's public username. # below a field meant to hold the user's public username.
username_instructions = _( username_instructions = _(
u"The name that will identify you in your courses - {bold_start}(cannot be changed later){bold_end}").format(bold_start=u'<strong>', bold_end=u'</strong>' u"The name that will identify you in your courses - "
) "{bold_start}(cannot be changed later){bold_end}"
).format(bold_start=u'<strong>', bold_end=u'</strong>')
# Translators: This example username is used as a placeholder in # Translators: This example username is used as a placeholder in
# a field on the registration form meant to hold the user's username. # a field on the registration form meant to hold the user's username.
......
...@@ -96,12 +96,16 @@ class TestPaverRunQuality(unittest.TestCase): ...@@ -96,12 +96,16 @@ class TestPaverRunQuality(unittest.TestCase):
# Underlying sh call must fail when it is running the pylint diff-quality task # Underlying sh call must fail when it is running the pylint diff-quality task
self._mock_paver_sh.side_effect = CustomShMock().fail_on_pylint self._mock_paver_sh.side_effect = CustomShMock().fail_on_pylint
with self.assertRaises(SystemExit): _mock_pep8_violations = MagicMock(return_value=(0, []))
pavelib.quality.run_quality("") with patch('pavelib.quality._get_pep8_violations', _mock_pep8_violations):
self.assertRaises(BuildFailure) with self.assertRaises(SystemExit):
pavelib.quality.run_quality("")
self.assertRaises(BuildFailure)
# Test that both pep8 and pylint were called by counting the calls # Test that both pep8 and pylint were called by counting the calls
# Pep8 is called twice (for lms and cms), then pylint is called an additional time. # Assert that _get_pep8_violations (which calls "pep8") is called once
self.assertEqual(self._mock_paver_sh.call_count, 3) self.assertEqual(_mock_pep8_violations.call_count, 1)
# And assert that sh was called once (for the call to "pylint")
self.assertEqual(self._mock_paver_sh.call_count, 1)
def test_other_exception(self): def test_other_exception(self):
""" """
......
...@@ -156,8 +156,6 @@ def _get_pep8_violations(): ...@@ -156,8 +156,6 @@ def _get_pep8_violations():
where violations_string is a string of all pep8 violations found, separated where violations_string is a string of all pep8 violations found, separated
by new lines. by new lines.
""" """
systems = ALL_SYSTEMS.split(',')
report_dir = (Env.REPORT_DIR / 'pep8') report_dir = (Env.REPORT_DIR / 'pep8')
report_dir.rmtree(ignore_errors=True) report_dir.rmtree(ignore_errors=True)
report_dir.makedirs_p() report_dir.makedirs_p()
...@@ -165,8 +163,7 @@ def _get_pep8_violations(): ...@@ -165,8 +163,7 @@ def _get_pep8_violations():
# Make sure the metrics subdirectory exists # Make sure the metrics subdirectory exists
Env.METRICS_DIR.makedirs_p() Env.METRICS_DIR.makedirs_p()
for system in systems: sh('pep8 . | tee {report_dir}/pep8.report -a'.format(report_dir=report_dir))
sh('pep8 {system} | tee {report_dir}/pep8.report -a'.format(system=system, report_dir=report_dir))
count, violations_list = _pep8_violations( count, violations_list = _pep8_violations(
"{report_dir}/pep8.report".format(report_dir=report_dir) "{report_dir}/pep8.report".format(report_dir=report_dir)
......
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