-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/pyta-uoft/pyta into repor…
…ting-errors-in-parsing-config
- Loading branch information
Showing
11 changed files
with
167 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Python script used for testing that the correct number of error occurrences are being displayed.""" | ||
from typing import List | ||
|
||
# The following imports are used solely to trigger errors. | ||
import packaging | ||
import pip | ||
import pygments | ||
import pylint | ||
|
||
|
||
def sum_items(lst: List[int]) -> int: | ||
"""...""" | ||
s = 0 | ||
for i in range(len(lst)): | ||
s += lst[i] | ||
return s | ||
|
||
|
||
def sum_items2(lst: List[int]) -> int: | ||
"""...""" | ||
s = 0 | ||
for i in range(0, len(lst)): | ||
s += lst[i] | ||
return s | ||
|
||
|
||
def sum_items3(lst: List[int]) -> int: | ||
"""...""" | ||
s = 0 | ||
for i in range(0, len(lst), 1): | ||
s += lst[i] | ||
return s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
Test suite for checking that the correct number of error occurrences are being displayed. | ||
""" | ||
|
||
import contextlib | ||
import io | ||
import os | ||
|
||
from python_ta import check_all | ||
|
||
|
||
def pyta_output(num_msgs: int) -> str: | ||
"""Returns the PythonTA report as a string.""" | ||
output = io.StringIO() | ||
|
||
curr_dir = os.path.dirname(__file__) | ||
test_file = os.path.join(curr_dir, "file_fixtures", "funcs_with_errors.py") | ||
|
||
with contextlib.redirect_stdout(output): | ||
check_all( | ||
module_name=test_file, | ||
config={ | ||
"pyta-number-of-messages": num_msgs, | ||
"output-format": "python_ta.reporters.JSONReporter", | ||
}, | ||
) | ||
|
||
return output.getvalue() | ||
|
||
|
||
def test_default() -> None: | ||
"""Tests that all messages are displayed when pyta-number-of-messages = 0.""" | ||
pyta_report = pyta_output(0) | ||
expected = 12 | ||
actual = pyta_report.count("msg_id") | ||
|
||
assert expected == actual | ||
|
||
|
||
def test_num_msgs2() -> None: | ||
"""Tests that only two messages per error are displayed when pyta-number-of-messages = 2.""" | ||
pyta_report = pyta_output(2) | ||
expected = 7 | ||
actual = pyta_report.count("msg_id") | ||
|
||
assert expected == actual | ||
|
||
|
||
def test_num_msgs_greater() -> None: | ||
"""Tests that all messages are displayed when pyta-number-of-messages is greater than the number of errors.""" | ||
pyta_report = pyta_output(5) | ||
expected = 12 | ||
actual = pyta_report.count("msg_id") | ||
|
||
assert expected == actual |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters