Skip to content

Commit 8bcd226

Browse files
authored
Merge pull request #2242 from jerneju/schema-test-examples
Scheme: test if scheme examples can be opened
2 parents f2c77bc + 3e8c484 commit 8bcd226

File tree

4 files changed

+276
-2
lines changed

4 files changed

+276
-2
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ recursive-include Orange/canvas/application/workflows *.ows
99

1010
recursive-include Orange/widgets *.png *.svg *.js *.css *.html
1111
recursive-include Orange/widgets/tests *.tab
12+
recursive-include Orange/widgets/tests/workflows *.ows
1213
recursive-include Orange/widgets/utils/plot *.fs *.vs *.gs *.obj
1314

1415
recursive-include distribute *.svg *.desktop
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from itertools import chain
2+
from os import listdir
3+
from os.path import isfile, join, dirname
4+
5+
from Orange.canvas.application import workflows
6+
from Orange.canvas.scheme import widgetsscheme
7+
from Orange.canvas.scheme.readwrite import scheme_load
8+
from Orange.widgets.tests.base import WidgetTest
9+
10+
11+
def discover_workflows(tests_dir):
12+
ows_path = join(tests_dir, "workflows")
13+
ows_files = [f for f in listdir(ows_path)
14+
if isfile(join(ows_path, f)) and f.endswith(".ows")]
15+
for ows_file in ows_files:
16+
yield join(ows_path, ows_file)
17+
18+
TEST_WORKFLOWS = chain(
19+
[t.abspath() for t in workflows.example_workflows()],
20+
discover_workflows(dirname(__file__))
21+
)
22+
23+
24+
class TestWorkflows(WidgetTest):
25+
def test_scheme_examples(self):
26+
"""
27+
Test if Orange workflow examples can be opened. Examples in canvas
28+
and also those placed "workflows" subfolder.
29+
GH-2240
30+
"""
31+
for ows_file in TEST_WORKFLOWS:
32+
new_scheme = widgetsscheme.WidgetsScheme()
33+
with open(ows_file, "rb") as f:
34+
try:
35+
scheme_load(new_scheme, f)
36+
except Exception as e:
37+
self.fail("Old workflow '{}' could not be loaded\n'{}'".
38+
format(ows_file, str(e)))

0 commit comments

Comments
 (0)