-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced "print" with "logging" in PythonTA check and check_contracts (…
- Loading branch information
1 parent
53a4cc7
commit 2ce5460
Showing
11 changed files
with
230 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# pylint: disable=unbalanced-tuple-unpacking |
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,5 @@ | ||
"�" | ||
"�" | ||
"foo" | ||
"foo" | ||
"�" |
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,29 @@ | ||
import logging | ||
|
||
from python_ta import contracts | ||
|
||
contracts.DEBUG_CONTRACTS = True | ||
from python_ta.contracts import check_contracts | ||
|
||
|
||
def test_contracts_debug(caplog) -> None: | ||
"""Test to see if _debug function is logging messages correctly""" | ||
caplog.set_level(logging.DEBUG) | ||
|
||
@check_contracts | ||
def divide(x: int, y: int) -> int: | ||
"""Return x // y. | ||
Preconditions: | ||
- invalid precondition | ||
""" | ||
return x // y | ||
|
||
divide(6, 2) | ||
|
||
for record in caplog.records: | ||
assert record.levelname == "DEBUG" | ||
assert ( | ||
"Warning: precondition invalid precondition could not be parsed as a valid Python expression" | ||
in caplog.text | ||
) |
Oops, something went wrong.