Skip to content

Commit

Permalink
Change print check regexp (oppia#5474)
Browse files Browse the repository at this point in the history
* Change print check regexp and add disable-bad-pattern-check option for a single line

* Fixes

* Remove print statements and reword sentences
  • Loading branch information
apb7 authored and kevinlee12 committed Aug 10, 2018
1 parent 7d3e1c4 commit 6c0ac4f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
5 changes: 2 additions & 3 deletions core/controllers/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ def test_that_no_get_results_in_500_error(self):

# Some of these will 404 or 302. This is expected.
response = self.testapp.get(url, expect_errors=True)
if response.status_int not in [200, 302, 400, 401, 404]:
print url
self.assertIn(response.status_int, [200, 302, 400, 401, 404])
self.assertIn(
response.status_int, [200, 302, 400, 401, 404], msg=url)

# TODO(sll): Add similar tests for POST, PUT, DELETE.
# TODO(sll): Set a self.payload attr in the BaseHandler for
Expand Down
8 changes: 4 additions & 4 deletions core/domain/exp_jobs_one_off_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ def test_for_creating_versions_of_image(self):
'html': (
'<p>Sorry, it doesn\'t look like your <span>program '
'</span>prints output</p>.<blockquote><p> Could you get '
'it to print something?</p></blockquote> Can do this by '
'it to do something?</p></blockquote> Can do this by '
'using statement like prints. <br> You can ask any if you '
'have<oppia-noninteractive-link url-with-value="&amp;quot;'
'https://www.example.com&amp;quot;" text-with-value="'
Expand Down Expand Up @@ -957,7 +957,7 @@ def test_for_validation_job(self):
'html': (
'<p>Sorry, it doesn\'t look like your <span>program '
'</span>prints output</p>.<blockquote><p> Could you get '
'it to print something?</p></blockquote> Can do this by '
'it to do something?</p></blockquote> Can do this by '
'using statement like prints. <br> You can ask any if you '
'have<oppia-noninteractive-link url-with-value="&amp;quot;'
'https://www.example.com&amp;quot;" text-with-value="'
Expand Down Expand Up @@ -988,7 +988,7 @@ def test_for_validation_job(self):
(
'[u\'strings\', [u\'<p>Sorry, it doesn\\\'t look '
'like your <span>program </span>prints output</p>.<blockquote>'
'<p> Could you get it to print something?</p></blockquote> '
'<p> Could you get it to do something?</p></blockquote> '
'Can do this by using statement like prints. <br> You can '
'ask any if you have<oppia-noninteractive-link text-with-value'
'="&amp;quot;Here&amp;quot;" url-with-value="&amp;quot;'
Expand Down Expand Up @@ -1052,7 +1052,7 @@ def test_for_migration_job(self):
'html': (
'<p>Sorry, it doesn\'t look like your <span>program '
'</span>prints output</p>.<blockquote><p> Could you get '
'it to print something?</p></blockquote> Can do this by '
'it to do something?</p></blockquote> Can do this by '
'using statement like prints. <br> You can ask any if you '
'have<oppia-noninteractive-link url-with-value="&amp;quot;'
'https://www.example.com&amp;quot;" text-with-value="'
Expand Down
1 change: 0 additions & 1 deletion core/tests/load_tests/feedback_thread_summaries_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,4 @@ def test_get_thread_summaries_load_test(self):
# Fetch the summaries of all the threads.
feedback_services.get_thread_summaries(self.user_id, thread_ids)
elapsed_time = time.time() - start
print "Time for fetching all the thread summaries -", elapsed_time
self.assertLessEqual(elapsed_time, 1.7)
4 changes: 3 additions & 1 deletion scripts/pre_commit_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@

BAD_PATTERNS_PYTHON_REGEXP = [
{
'regexp': r'print \'',
'regexp': r'print ',
'message': "Please do not use print statement.",
'excluded_files': (
'core/tests/test_utils.py',
Expand Down Expand Up @@ -785,6 +785,8 @@ def _check_bad_pattern_in_file(filename, content, pattern):
or filename in pattern['excluded_files']):
bad_pattern_count = 0
for line_num, line in enumerate(content.split('\n'), 1):
if line.endswith('disable-bad-pattern-check'):
continue
if re.search(regexp, line):
print '%s --> Line %s: %s' % (
filename, line_num, pattern['message'])
Expand Down

0 comments on commit 6c0ac4f

Please sign in to comment.