Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Remove pep8 and add pycodestyle. (#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-canon authored Mar 12, 2020
1 parent 6401e27 commit f70928f
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ course_validation:
python -m acceptance_tests.course_validation.generate_report

quality:
pep8 acceptance_tests analytics_dashboard common
pycodestyle acceptance_tests analytics_dashboard common
PYTHONPATH=".:./analytics_dashboard:$PYTHONPATH" pylint --rcfile=pylintrc acceptance_tests analytics_dashboard common

validate_python: test.requirements test_python quality
Expand Down
1 change: 1 addition & 0 deletions acceptance_tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def str2bool(s):
s = six.text_type(s)
return s.lower() in (u"yes", u"true", u"t", u"1")


# Dashboard settings
DASHBOARD_SERVER_URL = os.environ.get('DASHBOARD_SERVER_URL', 'http://localhost:9000')
DASHBOARD_FEEDBACK_EMAIL = os.environ.get('DASHBOARD_FEEDBACK_EMAIL', '[email protected]')
Expand Down
4 changes: 2 additions & 2 deletions analytics_dashboard/core/tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def assertIsServiceUnavailableErrorResponse(self, response):
def test_process_exception(self):
request = self.factory.get('/')
self.assertStandardExceptions(request)
with LogCapture(level=logging.WARN) as l:
with LogCapture(level=logging.WARN) as log_capture:
exception = ServiceUnavailableError()
response = self.middleware.process_exception(request, exception)
self.assertIsServiceUnavailableErrorResponse(response)

# Verify the exception was logged
l.check(('core.middleware', 'ERROR', str(exception)),)
log_capture.check(('core.middleware', 'ERROR', str(exception)),)
10 changes: 6 additions & 4 deletions analytics_dashboard/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,23 @@ def test_status(self):

@mock.patch('analyticsclient.status.Status.healthy', mock.PropertyMock(return_value=True))
def test_healthy(self):
with LogCapture(level=logging.ERROR) as l:
with LogCapture(level=logging.ERROR) as log_capture:
self.verify_health_response(
expected_status_code=200, overall_status=OK, database_connection=OK
)
l.check()
log_capture.check()

@mock.patch('analyticsclient.status.Status.healthy', mock.PropertyMock(return_value=True))
@mock.patch('django.db.backends.base.base.BaseDatabaseWrapper.cursor',
mock.Mock(side_effect=DatabaseError('example error')))
def test_health_database_outage(self):
with LogCapture(level=logging.ERROR) as l:
with LogCapture(level=logging.ERROR) as log_capture:
self.verify_health_response(
expected_status_code=503, overall_status=UNAVAILABLE, database_connection=UNAVAILABLE
)
l.check(('analytics_dashboard.core.views', 'ERROR', 'Insights database is not reachable: example error'))
log_capture.check(
('analytics_dashboard.core.views', 'ERROR', 'Insights database is not reachable: example error')
)


class LoginViewTests(RedirectTestCaseMixin, TestCase):
Expand Down
4 changes: 2 additions & 2 deletions analytics_dashboard/courses/tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ def test_process_exception(self):
# Method should return None if exception argument is NOT PermissionsRetrievalFailedError.
self.assertStandardExceptions(request)

with LogCapture(level=logging.WARN) as l:
with LogCapture(level=logging.WARN) as log_capture:
# Method should only return a response for PermissionsRetrievalFailedError.
exception = PermissionsRetrievalFailedError()
response = self.middleware.process_exception(request, exception)
self.assertIsPermissionsRetrievalFailedResponse(response)

# Verify the exception was logged
l.check(('courses.middleware', 'ERROR', str(exception)),)
log_capture.check(('courses.middleware', 'ERROR', str(exception)),)
2 changes: 1 addition & 1 deletion requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ path.py==11.5.2 # via -r requirements/test.txt, edx-i18n-tools
pathlib2==2.3.5 # via -r requirements/test.txt, importlib-metadata, pytest, pytest-django
pbr==5.4.4 # via -r requirements/test.txt, mock, stevedore
pep257==0.7.0 # via -r requirements/test.txt
pep8==1.7.1 # via -r requirements/test.txt
pillow==6.2.2 # via -r requirements/test.txt, needle
pinax-announcements==2.0.4 # via -r requirements/test.txt
pip-tools==4.5.1 # via -r requirements/pip_tools.txt
pluggy==0.13.1 # via -r requirements/test.txt, pytest
polib==1.1.0 # via -r requirements/test.txt, edx-i18n-tools
psutil==1.2.1 # via -r requirements/test.txt, edx-django-utils
py==1.8.1 # via -r requirements/test.txt, pytest
pycodestyle==2.5.0 # via -r requirements/test.txt
pycryptodomex==3.9.7 # via -r requirements/test.txt, pyjwkest
pygments==2.5.2 # via -r requirements/test.txt, bpython
pyjwkest==1.4.2 # via -r requirements/test.txt, edx-drf-extensions
Expand Down
2 changes: 1 addition & 1 deletion requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ unittest2==1.1.0
httpretty==0.8.14
mock==1.3.0
pep257
pep8
pycodestyle
pylint==1.7.1
logilab-common==1.4.0
selenium>=2.44.0,<3.0.0
Expand Down
2 changes: 1 addition & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ path.py==11.5.2 # via -r requirements/base.txt, edx-i18n-tools
pathlib2==2.3.5 # via -r requirements/base.txt, importlib-metadata, pytest, pytest-django
pbr==5.4.4 # via -r requirements/base.txt, mock, stevedore
pep257==0.7.0 # via -r requirements/test.in
pep8==1.7.1 # via -r requirements/test.in
pillow==6.2.2 # via needle
pinax-announcements==2.0.4 # via -r requirements/base.txt
pluggy==0.13.1 # via pytest
polib==1.1.0 # via -r requirements/base.txt, edx-i18n-tools
psutil==1.2.1 # via -r requirements/base.txt, edx-django-utils
py==1.8.1 # via pytest
pycodestyle==2.5.0 # via -r requirements/test.in
pycryptodomex==3.9.7 # via -r requirements/base.txt, pyjwkest
pygments==2.5.2 # via -r requirements/base.txt, bpython
pyjwkest==1.4.2 # via -r requirements/base.txt, edx-drf-extensions
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[pep8]
[pycodestyle]
max_line_length=120
exclude=settings,migrations,analytics_dashboard/static,node_modules,analytics_dashboard/wsgi.py

0 comments on commit f70928f

Please sign in to comment.