test_numb3rs.py giving trouble
Hey all,
So, I am struggling fix the red checks after running check50 on my numb3rs project, screenshot is attached. And I tried to go through the project specifications again to understand, but I couldn't understand the specifications, so I would be glad if someone could explain in crystal clear and basic words what the below means:
To test your tests, run
pytest test_numb3rs.py. Try to use correct and incorrect versions ofnumb3rs.pyto determine how well your tests spot errors:
- Ensure you have a correct version of
numb3rs.py. Run your tests by executingpytest test_numb3rs.py.pytestshould show that all of your tests have passed. - Modify the
validatefunction in the correct version ofnumb3rs.py.validatemight, for example, only check whether the first byte of the IPv4 address is valid. Run your tests by executingpytest test_numb3rs.py.pytestshould show that at least one of your tests has failed. - Again modify the correct version of
numb3rs.py.validatemight, for example, mistakenly returnTruewhen the user inputs an incorrect IPv4 format. Run your tests by executingpytest test_numb3rs.py.pytestshould show that at least one of your tests has failed.
So I think the above description is what might fix my problem, so below is the code for test file:
import pytest
from numb3rs import validate
def test_true():
assert validate("127.0.0.1") == "True"
assert validate("255.255.255.255") == "True"
assert validate("140.247.235.144") == "True"
def test_false():
assert validate("256.255.255.255") == "False"
assert validate("64.128.256.512") == "False"
def test_length():
assert validate("8.8.8") == "False"
assert validate("10.10.10.10.10") == "False"
def test_tricky():
assert validate("2001:0db8:85a3:0000:0000:8a2e:0370:7334") == "False"
assert validate("cat") == "False"
So, would be glad if anybody could help me with this, been working on this for more than 4 hours.
Thanks!
Posted Apr 5, 2026, 10:13 AM UTC
14