-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
67 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="6" time="0.090" timestamp="2024-08-09T17:54:22.016303-04:00" hostname="Dingkuns-MBP.attlocal.net"><testcase classname="tests.test_extract_countries" name="test_get_contents_of_file" time="0.004" /><testcase classname="tests.test_extract_countries" name="test_get_country_dict" time="0.000" /><testcase classname="tests.test_extract_countries" name="test_print_results" time="0.001" /><testcase classname="tests.test_shopping_list" name="test_change_shopping_list" time="0.001" /><testcase classname="tests.test_slack_add" name="test_add_two_numbers" time="0.001" /><testcase classname="tests.test_the_meaning_of_life" name="test_the_meaning_of_life" time="0.001" /></testsuite></testsuites> |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,20 @@ | ||
"""Module to add two numbers that input from the user, and print the sum of them.""" | ||
|
||
|
||
def add_two_numbers() -> None: | ||
""" | ||
Function to add two numbers that input from the user, | ||
and print the sum of them. | ||
""" | ||
try: | ||
number1 = int(input("Enter the first number you want to add:\n")) | ||
number2 = int(input("Enter the second number you want to add:\n")) | ||
except ValueError: | ||
print("Invalid input. Please enter valid integers.") | ||
exit(1) | ||
nums_sum = number1 + number2 | ||
print(f"The sum of {number1} and {number2} is {nums_sum}.") | ||
|
||
|
||
if __name__ == "__main__": | ||
add_two_numbers() |
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,19 @@ | ||
"""Module to test the add_two_numbers function from slack_add.py.""" | ||
|
||
from unittest.mock import patch | ||
from slack_add import add_two_numbers # type: ignore | ||
|
||
|
||
def test_add_two_numbers() -> None: | ||
""" | ||
Test that the function add_two_numbers() prints the correct sum. | ||
""" | ||
with patch("builtins.input", side_effect=[2, 3]), patch( | ||
"builtins.print" | ||
) as mocked_print: | ||
add_two_numbers() | ||
|
||
expected_output = "The sum of 2 and 3 is 5." | ||
actual_output = mocked_print.call_args_list[0][0][0] | ||
|
||
assert actual_output == expected_output |