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

unit test and something interesting #10

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

JessieLu20
Copy link

Answers UCL-COMP0233-24-25/RSE-Classwork#11

in the test_times.py, if import the original codes as 'from .times import *', would raise error when testing; Strange because it is also correct format as import.

==================================================================== test session starts =====================================================================
platform win32 -- Python 3.10.14, pytest-8.3.3, pluggy-1.5.0
rootdir: D:\SDIC\term1\COMP0233_software_python\week5\time-tests
plugins: anyio-4.2.0
collected 0 items / 1 error

=========================================================================== ERRORS =========================================================================== 
plugins: anyio-4.2.0
collected 0 items / 1 error                                                                                                                                    

=========================================================================== ERRORS =========================================================================== 
_______________________________________________________________ ERROR collecting test_times.py _______________________________________________________________ 
ImportError while importing test module 'D:\SDIC\term1\COMP0233_software_python\week5\time-tests\test_times.py'.
Hint: make sure your test modules/packages have valid Python names.
_______________________________________________________________ ERROR collecting test_times.py _______________________________________________________________ 
ImportError while importing test module 'D:\SDIC\term1\COMP0233_software_python\week5\time-tests\test_times.py'.
Hint: make sure your test modules/packages have valid Python names.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\Users\hanlu\miniconda3\envs\pytorch\lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
test_times.py:2: in <module>
    from .times import *
E   ImportError: attempted relative import with no known parent package
================================================================== short test summary info =================================================================== 
ERROR test_times.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
====================================================================== 1 error in 0.23s ======================================================================

times.py Outdated
Comment on lines 23 to 28
for start2, end2 in range2:
low = max(start1, start2)
high = min(end1, end2)
overlap_time.append((low, high))
# bug fixing: only overlapping exists, below min/max range satisfy
if start2<=end1 and end2>=start1:
low = max(start1, start2)
high = min(end1, end2)
overlap_time.append((low, high))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a bug in original code, we must ensure there is a reasonable overlap here

test_times.py Outdated
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_times.py Outdated
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utilize the pytest.mark.parametrize to dry the multi tests
Answers UCL-COMP0233-24-25/RSE-Classwork#16

@JessieLu20
Copy link
Author

Load the yaml file within the test and use it that structure to feed the parametrize test.
Answers UCL-COMP0233-24-25/RSE-Classwork#17

@JessieLu20
Copy link
Author

Mocking a web service for the International Space Station
Answers UCL-COMP0233-24-25/RSE-Classwork#18

@JessieLu20
Copy link
Author

image
image

Answers UCL-COMP0233-24-25/RSE-Classwork#15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant