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

Added test file for is_number #2146

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions very_easy/is_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ def check_number(input_value: Any) -> str:
print(check_number(pow(10, 20)))
print(check_number("Hello"))
print(check_number(1 + 2j))

23 changes: 23 additions & 0 deletions very_easy/test_is_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest

from is_number import check_number

def test_check_number_float():
assert check_number(3.14) == '3.14 is a number.'
assert check_number(1e-5) == '1e-05 is a number.'

def test_check_number_negative_float():
assert check_number(-3.14) == '-3.14 is a number.'
assert check_number(-1e-5) == '-1e-05 is a number.'

def test_check_number_boolean():
assert check_number(True) == 'True is a number.'
assert check_number(False) == 'False is a number.'

def test_check_number_list():
assert check_number([1, 2, 3]) == '[1, 2, 3] is not a number.'
assert check_number([]) == '[] is not a number.'

def test_check_number_dict():
assert check_number({'key': 'value'}) == "{'key': 'value'} is not a number."
assert check_number({}) == "{} is not a number."