-
Notifications
You must be signed in to change notification settings - Fork 94
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
Increase coverage for the parsec package #2839
Conversation
6661f37
to
b40004f
Compare
(note: I had a bunch of codacy-bot comments open... the moment I updated my branch they appeared as "hjoliver deleted a comment...", so it appears this happens while an analysis is happening.. the bot just goes, deletes all comments, and then once finished new comments will pop-up. When deleting, the user that appears is the repo admin, I reckon) |
b40004f
to
fd7b0f0
Compare
fd7b0f0
to
dfba536
Compare
Fixed the Codacy issues that seemed easy to fix and reasonable. Others I think are OK. Used a temporary branch merged with the coverage pull request, and it reported an overall increase of +4.84%. Going from ~54% to 59.3%, above our threshold. Also found an issue with the coverage reports, updated the pull request for test coverage, and that might also be the solution for the weird coverage results that we had in |
Ah ha! Nice detective work. |
~60% coverage is heading towards "semi-reasonable" (under the circumstances)! |
dfba536
to
d09e2e6
Compare
The only issue is that |
63435bd
to
0c6f42f
Compare
@matthewrmshin oh, sorry, I marked only one of the two With empy: kinow@kinow-VirtualBox:~/Development/python/workspace/cylc$ PYTHONPATH=$(pwd -P)/lib pytest lib/parsec/tests/test_empysupport.py
=============================================================================================== test session starts ===============================================================================================
platform linux2 -- Python 2.7.15rc1, pytest-3.9.1, py-1.7.0, pluggy-0.8.0
rootdir: /home/kinow/Development/python/workspace/cylc, inifile:
plugins: cov-2.6.0
collected 2 items
lib/parsec/tests/test_empysupport.py .. After kinow@kinow-VirtualBox:~/Development/python/workspace/cylc$ PYTHONPATH=$(pwd -P)/lib pytest lib/parsec/tests/test_empysupport.py
=============================================================================================== test session starts ===============================================================================================
platform linux2 -- Python 2.7.15rc1, pytest-3.9.1, py-1.7.0, pluggy-0.8.0
rootdir: /home/kinow/Development/python/workspace/cylc, inifile:
plugins: cov-2.6.0
collected 2 items
lib/parsec/tests/test_empysupport.py ss Instead of the dots representing the test cases, we have the 👍 Sorry for that, and thanks for spotting it! Rebased branch onto master. Bruno |
0c6f42f
to
00fa0ab
Compare
Unit test for diff --git a/lib/parsec/tests/test_validate.py b/lib/parsec/tests/test_validate.py
index 044d94c49..dc327c9c6 100644
--- a/lib/parsec/tests/test_validate.py
+++ b/lib/parsec/tests/test_validate.py
@@ -111,20 +111,18 @@ class TestValidate(unittest.TestCase):
def test_list_value_error(self):
keys = ['a,', 'b', 'c']
value = 'a sample value'
- error = ListValueError(keys, value)
+ error = ListValueError(keys, value, 'who cares:')
output = error.msg
- expected = "ERROR: names containing commas must be quoted" \
- " (e.g. 'foo<m,n>'):\n [a,][b]c = a sample value"
+ expected = "who cares:\n [a,][b]c = a sample value"
self.assertEqual(expected, output)
def test_list_value_error_with_exception(self):
keys = ['a,', 'b', 'c']
value = 'a sample value'
exc = Exception('test')
- error = ListValueError(keys, value, exc)
+ error = ListValueError(keys, value, 'who cares:', exc)
output = error.msg
- expected = "ERROR: names containing commas must be quoted" \
- " (e.g. 'foo<m,n>'):\n [a,][b]c = a sample value: test"
+ expected = "who cares:\n [a,][b]c = a sample value: test"
self.assertEqual(expected, output)
def test_illegal_value_error(self): |
00fa0ab
to
df8f78c
Compare
Thanks for the fix @matthewrmshin ! It worked like a charm in my environment, so simply replicated in the branch + rebase/squash. $ PYTHONPATH=$(pwd -P)/lib pytest lib/parsec
======================================================================================== test session starts ========================================================================================
platform linux2 -- Python 2.7.15rc1, pytest-3.9.1, py-1.7.0, pluggy-0.8.0
rootdir: /home/kinow/Development/python/workspace/cylc, inifile:
plugins: cov-2.6.0
collected 112 items
lib/parsec/tests/test_config.py ........ [ 7%]
lib/parsec/tests/test_empysupport.py .. [ 8%]
lib/parsec/tests/test_fileparse.py .................... [ 26%]
lib/parsec/tests/test_include.py .... [ 30%]
lib/parsec/tests/test_jinja2support.py ....... [ 36%]
lib/parsec/tests/test_ordered_dict.py ........... [ 46%]
lib/parsec/tests/test_parsec.py .. [ 48%]
lib/parsec/tests/test_upgrade.py ........... [ 58%]
lib/parsec/tests/test_util.py ....................... [ 78%]
lib/parsec/tests/test_validate.py ........................ [100%]
==================================================================================== 112 passed in 0.31 seconds ===================================================================================== |
(I'll press merge when Travis CI is done.) |
Sadly I have just established that at more than one of these tests does not work for Python 2.6. Compare the result of:
To see the full listings, copy & run However, these failures are mostly of the same instance, e.g. most commonly from |
From the Python 2.7 docs: "Changed in version 2.7: Added the ability to use assertRaises() as a context manager." Using it as a bare assert statement would make sub-tests in question pass for v. 2.6, but I do not think this is worth the effort to amend in each instance, given we know it is a quirk of the tests & not an issue in the parsec code & especially as a However, I will still tweak any 2.6 failures not due to the above. They are, exclusively:
I am now amending (1) |
Thanks for fixing the tests on 2.6! My IDE spotted a few compatibility issues for 2.6, but without a 2.6 interpreter, it is harder to make sure it works. |
Hi,
This pull request includes changes only to test files. And there are only unit tests. The old tests for the
validate
module were moved intotest_validate
. This way they can be executed with any test runner (pytest
,nose
, etc), and it is also easier to gather coverage.Running the tests in the command line:
In my IDE, the 122 tests run in 0.211s. And it displays 74% of files covered in the
parsec
package, and 90% of lines.I ignored the
OrderedDictCompat.py
as we will probably delete this file during the move to Python 3+.I am hoping Travis-CI will be happy with the new tests. But I will create another branch in separate, with the coverage enabled to see how much the total coverage (which was around 55% in the other pull request) will increase for the project.
I enabled Code Compatibility in my IDE for Python 2.6, and it did detect a few errors. But I couldn't find an installation from Anaconda with Python 2.6, so alas @oliver-sanders might find some more slips of mine for that version :-(
For me these tests are enough to start hacking the files under the
parsec
package, and moving to Python 3 - in the near future. Planning to have a similar approach to other packages/modules... especially files like the ones containing the scheduler, suite manager, task pool, etc. This is covering just the parsing of RC and templating I think.Cheers
Bruno