-
Notifications
You must be signed in to change notification settings - Fork 54
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
Move from nosetest to pytest #2322
Conversation
@@ -216,7 +216,7 @@ def get_proxy_config(): | |||
if config_file: | |||
_log.info("Configuring KBase logging from file '{}'".format(config_file)) | |||
else: | |||
_log.warn( | |||
_log.warning( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a deprecation warning.
@@ -61,7 +61,7 @@ def __init__(self, input_file): | |||
if not isinstance(input_file, IOBase): | |||
input_file = open(str(input_file), "r") | |||
try: | |||
self._obj = yaml.load(input_file) | |||
self._obj = yaml.load(input_file, Loader=yaml.SafeLoader) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another deprecation warning. Really, both log_proxy
and kblogging
aren't in use, I don't believe, but this was safe enough.
@@ -6,7 +6,6 @@ jinja2==2.11.3 | |||
jsonschema==3.2.0 | |||
markupsafe==1.1.1 | |||
mock==4.0.3 | |||
nose>=1.1.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bye bye nose!
@@ -1,4 +1,4 @@ | |||
from ..util import TestConfig | |||
from ..util import ConfigTests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The remaining changes go from TestConfig
-> ConfigTests
in the rest of these files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Kudos, SonarCloud Quality Gate passed!
|
Codecov Report
@@ Coverage Diff @@
## develop #2322 +/- ##
===========================================
+ Coverage 12.91% 17.16% +4.25%
===========================================
Files 415 451 +36
Lines 44581 48263 +3682
===========================================
+ Hits 5757 8285 +2528
- Misses 38824 39978 +1154
Continue to review full report at Codecov.
|
Description of PR purpose/changes
The original motivation for this PR was found in the previous PR #2321 - Python code unit test coverage wasn't properly being uploaded to codecov. After a little poking, it seems that it's not being generated properly. Should be easy enough. I was also inspired to look at moving from nose to pytest at the same time.
So this is the first step (of likely many, TBA) in updating the Python test stack to be a little more modern. Nose is an ancient way of running Python tests. It has served us well, but it is long past time to move on. https://nose.readthedocs.io/en/latest/
Pytest is a framework that's used more commonly in the Python world, and at KBase in other projects. It has good support for test fixtures and mocking, and is under active community support. Best of all, it's basically a drop-in replacement! Seriously, the main change to get this running was to add it to
requirements.txt
, and change the call inscripts/narrative_backend_tests.sh
. This exposed a number of minor warnings that were also changed - notably, any class in the test directory withTest
as its first token is treated as a test, which got noisy. So theutil.TestConfig
class is nowutil.ConfigTests
, for example.A few other warnings popped up that were trivial to change, as well.
This does alter the
requirements.txt
file, so be sure to do a new installation locally in order to run tests.DATAUP-69 Adds a PR template
)Testing Instructions
Dev Checklist:
Updating Version and Release Notes (if applicable)