-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Scheme: test if scheme examples can be opened #2242
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2242 +/- ##
=========================================
Coverage ? 73.01%
=========================================
Files ? 316
Lines ? 55192
Branches ? 0
=========================================
Hits ? 40300
Misses ? 14892
Partials ? 0 |
Make sure you add new paths that should be included in distribution to MANIFEST and setup.py (package_data). |
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.
While we try to follow most of the lints suggestions, doing so blindly without understanding the consequences is a bad idea. Import order in setup.py matter, as one library (setuptools) might patch the other (distutils) and having a specific order of imports ensures that we get and use the patched methods.
The test looks ok, just try to refactor it a bit to make it easier to add addition workflows in the future. I have included some suggestions in the code.
setup.py
Outdated
@@ -3,6 +3,7 @@ | |||
import os | |||
import sys | |||
import subprocess | |||
from distutils.command.build_ext import build_ext |
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.
Please revert this.
setup.py
Outdated
@@ -228,7 +229,7 @@ def run(self): | |||
|
|||
|
|||
|
|||
class build_ext_error(build_ext): | |||
class BuildExtError(build_ext): |
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.
and this.
and also those placed "workflows" subfolder. | ||
GH-2240 | ||
""" | ||
def test(filename): |
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.
convert this function to a (static) method on the class. name it something along the lines of "assertCanBeLoaded".
Add some error handling code to the test that would catch the error and fail the test with the name of the workflow that could not be loaded. When the tests fails, the name of the problematic workflow will be much more useful than the actual exception (as it will allow us to run and debug the problematic workflow).
with open(filename, "rb") as f: | ||
scheme_load(new_scheme, f) | ||
|
||
tutors = workflows.example_workflows() |
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.
Move the specification of the workflows to be tested outside of the tests. I define them in a constant on a module level that would look like this:
TEST_WORKFLOWS=itertools.chain(
workflows.example_workflows(),
discover_workflows(dirname(__file__))
)
(I assume that you write a function discover_workflows that gets a path to a dir and yields all .ows files it finds by traversing the directory) This would simplify the test to the point where the checks in test() function could be written in the body of the for loop that iterates through the TEST_WORKFLOWS.
try: | ||
scheme_load(new_scheme, f) | ||
except UnknownWidgetDefinition as e: | ||
log.error("Unknown widget '%s' while loading '%s'.", |
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.
use self.fail instead of logging and then raising.
exc_info=True) | ||
raise | ||
except Exception: | ||
log.error("Error occurred while loading '%s'.", |
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.
same here
GH-2240 | ||
""" | ||
for ows_file in TEST_WORKFLOWS: | ||
self.assertCanBeLoaded(ows_file) |
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.
as this test is pretty short now, what about moving the content of the assert method back to the test?
@astaric: Should I write another test to increase codecov/patch diff hit? |
Issue
#2240
Description of changes
Includes