Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add line number in errors for easy debugging #358

Merged
merged 1 commit into from
Mar 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pydatastructs/utils/tests/test_code_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ def test_trailing_white_spaces():
for file_path in py_files:
file = open(file_path, "r")
line = file.readline()
line_number = 1
while line != "":
if line.endswith(" \n") or line.endswith("\t\n") \
or line.endswith(" ") or line.endswith("\t"):
assert False, "%s contains trailing whitespace at %s"\
%(file_path, line)
assert False, "%s contains trailing whitespace at line number %d: %s"\
%(file_path, line_number, line)
line = file.readline()
line_number += 1
file.close()

def test_final_new_lines():
Expand All @@ -46,6 +48,7 @@ def test_comparison_True_False_None():
if file_path.find("test_code_quality.py") == -1:
file = open(file_path, "r")
line = file.readline()
line_number = 1
while line != "":
if ((line.find("== True") != -1) or
(line.find("== False") != -1) or
Expand All @@ -54,9 +57,10 @@ def test_comparison_True_False_None():
(line.find("!= False") != -1) or
(line.find("!= None") != -1)):
assert False, "%s compares True/False/None using by "\
"value, should be done by reference at %s"\
%(file_path, line)
"value, should be done by reference at line number %d: %s"\
%(file_path, line_number, line)
line = file.readline()
line_number += 1
file.close()

def test_presence_of_tabs():
Expand Down