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

Scheme: test if scheme examples can be opened #2242

Merged
merged 2 commits into from
May 9, 2017
Merged

Scheme: test if scheme examples can be opened #2242

merged 2 commits into from
May 9, 2017

Conversation

jerneju
Copy link
Contributor

@jerneju jerneju commented Apr 18, 2017

Issue

#2240

Description of changes
Includes
  • Code changes
  • Tests
  • Documentation

@codecov-io
Copy link

codecov-io commented Apr 18, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@3541d65). Click here to learn what that means.
The diff coverage is 90.9%.

@@            Coverage Diff            @@
##             master    #2242   +/-   ##
=========================================
  Coverage          ?   73.01%           
=========================================
  Files             ?      316           
  Lines             ?    55192           
  Branches          ?        0           
=========================================
  Hits              ?    40300           
  Misses            ?    14892           
  Partials          ?        0

@jerneju
Copy link
Contributor Author

jerneju commented Apr 18, 2017

@astaric : Tests Orange/canvas/scheme/tests are turned off. This test should fail now but it will probably pass when #2241 and #2243 are merged.

@astaric
Copy link
Member

astaric commented Apr 19, 2017

Make sure you add new paths that should be included in distribution to MANIFEST and setup.py (package_data).

@jerneju jerneju changed the title [WIP] Scheme: test if scheme examples can be opened Scheme: test if scheme examples can be opened Apr 21, 2017
Copy link
Member

@astaric astaric left a 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
Copy link
Member

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):
Copy link
Member

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):
Copy link
Member

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()
Copy link
Member

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'.",
Copy link
Member

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'.",
Copy link
Member

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)
Copy link
Member

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?

@jerneju
Copy link
Contributor Author

jerneju commented May 5, 2017

@astaric: Should I write another test to increase codecov/patch diff hit?

@astaric astaric merged commit 8bcd226 into biolab:master May 9, 2017
@jerneju jerneju deleted the schema-test-examples branch May 9, 2017 13:28
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.

3 participants