Update 'make test' to run all unit tests#143
Conversation
Codecov Report
@@ Coverage Diff @@
## master #143 +/- ##
==========================================
+ Coverage 61.98% 85.9% +23.92%
==========================================
Files 31 31
Lines 1168 1185 +17
==========================================
+ Hits 724 1018 +294
+ Misses 444 167 -277
Continue to review full report at Codecov.
|
| # https://github.com/HumanCellAtlas/dcp-cli/issues/127 | ||
| coverage run --source=hca -m unittest discover -v -t . -s test/upload | ||
| coverage run --source=hca -m unittest discover -v -t . -s test -p test_dss_*.py | ||
| coverage run --source=hca -m unittest discover -v -t . -s test -p test_*.py |
There was a problem hiding this comment.
I would just remove the -p parameter. The default 'test*.py' seems reasonable. Furthermore, I think without quotes, this could potentially expand to a path.
There was a problem hiding this comment.
Do you know what the flags -s and -p do? I don't see -s in the docs, and -p doesn't seem to mean --parallel-mode since removing it breaks the command:
coverage run --source=hca -m unittest discover -v -t . -s test test*.py
Traceback (most recent call last):
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/__main__.py", line 12, in <module>
main(module=None)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 94, in __init__
self.parseArgs(argv)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 113, in parseArgs
self._do_discovery(argv[2:])
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 214, in _do_discovery
self.test = loader.discover(start_dir, pattern, top_level_dir)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 204, in discover
raise ImportError('Start directory is not importable: %r' % start_dir)
ImportError: Start directory is not importable: 'test*.py'
Coverage.py warning: No data was collected. (no-data-collected)
make: *** [test] Error 1
There was a problem hiding this comment.
Just make it coverage run --source=hca -m unittest discover -v -t . -s test
% python -m unittest --help
usage: python -m unittest [-h] [-v] [-q] [--locals] [-f] [-c] [-b]
[tests [tests ...]]
positional arguments:
tests a list of any number of test modules, classes and test
methods.
optional arguments:
-h, --help show this help message and exit
-v, --verbose Verbose output
-q, --quiet Quiet output
--locals Show local variables in tracebacks
-f, --failfast Stop on first fail or error
-c, --catch Catch Ctrl-C and display results so far
-b, --buffer Buffer stdout and stderr during tests
Examples:
python -m unittest test_module - run tests from test_module
python -m unittest module.TestClass - run tests from module.TestClass
python -m unittest module.Class.test_method - run specified test method
python -m unittest path/to/test_file.py - run tests from test_file.py
usage: python -m unittest discover [-h] [-v] [-q] [--locals] [-f] [-c] [-b]
[-s START] [-p PATTERN] [-t TOP]
optional arguments:
-h, --help show this help message and exit
-v, --verbose Verbose output
-q, --quiet Quiet output
--locals Show local variables in tracebacks
-f, --failfast Stop on first fail or error
-c, --catch Catch Ctrl-C and display results so far
-b, --buffer Buffer stdout and stderr during tests
-s START, --start-directory START
Directory to start discovery ('.' default)
-p PATTERN, --pattern PATTERN
Pattern to match tests ('test*.py' default)
-t TOP, --top-level-directory TOP
Top level directory of project (defaults to start
directory)
For test discovery all test modules must be importable from the top level
directory of the project.
There was a problem hiding this comment.
Ah, I was checking the coverage docs. I guess I overlooked the -m unittest. Thanks!
7bacd0e to
185f98e
Compare
|
Thanks to @Bento007, we realized the coverage increase was the result of running 1 |
|
👍 |
Actually, with this change,
make testdoesn't run any more tests than the old one (both run 54 tests), but overall code coverage increases by ~25%. Not sure what's going on here, but I'm inclined to ignore this coverage increase (and close this PR) if we can't explain why it's happening.