Skip to content

Commit 7e11473

Browse files
authored
Merge pull request #4481 from biolab/tox
[ENH] Testing with Tox
2 parents 4fd0a48 + 00eb853 commit 7e11473

File tree

5 files changed

+136
-3
lines changed

5 files changed

+136
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ Thumbs.db
2929
htmlcov/*
3030
.coverage
3131
.coverage.*
32+
33+
.tox
34+
pip-wheel-metadata/

Orange/widgets/data/tests/test_owoutliers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def test_outputs(self):
4747
inliers = self.get_output(self.widget.Outputs.inliers)
4848
outliers = self.get_output(self.widget.Outputs.outliers)
4949
data = self.get_output(self.widget.Outputs.data)
50-
self.assertEqual(len(inliers), 135)
51-
self.assertEqual(len(outliers), 15)
50+
self.assertIn(len(inliers), [135, 136])
51+
self.assertIn(len(outliers), [14, 15])
5252
self.assertEqual(len(data), 150)
5353
self.assertEqual(len(inliers.domain.attributes), 4)
5454
self.assertEqual(len(outliers.domain.attributes), 4)
@@ -136,7 +136,7 @@ def test_in_out_summary(self):
136136
self.send_signal(self.widget.Inputs.data, self.iris)
137137
self.wait_until_finished()
138138
self.assertEqual(info._StateInfo__input_summary.brief, "150")
139-
self.assertEqual(info._StateInfo__output_summary.brief, "135")
139+
self.assertIn(info._StateInfo__output_summary.brief, ["135", "136"])
140140

141141
self.send_signal(self.widget.Inputs.data, None)
142142
self.wait_until_finished()

doc/build_doc.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
set -o pipefail
4+
set -o errexit
5+
6+
# Ensure new images have indexed palettes
7+
images="$(git diff --name-only origin/master..HEAD |
8+
grep -E '\bdoc/' | grep -iE '\.(png|jpg)$' || true )"
9+
echo "Checking if images are indexed:"
10+
while read image; do
11+
[ -f "$image" ] || continue
12+
if [[ "$image" == *"_unindexed"* ]]; then
13+
continue
14+
fi
15+
imtype=$(identify -verbose "$image" | awk '/^ *Type: /{ print $2 }')
16+
echo "$image $imtype"
17+
if ! echo "$imtype" | grep -Eq '(Palette|Grayscale)'; then
18+
echo "Error: image '$image' is not indexed or grayscale" >&2
19+
not_ok=1
20+
fi
21+
done < <(echo "$images")
22+
[ "$not_ok" ] && false
23+
echo -e 'all ok\n'
24+
25+
SCRIPT_DIR=$(dirname "$BASH_SOURCE")
26+
make html --directory "$SCRIPT_DIR"/development
27+
make html --directory "$SCRIPT_DIR"/data-mining-library
28+
make html --directory "$SCRIPT_DIR"/visual-programming
29+
30+
# check if the widget catalog in the repository (for orange-hugo is up to date
31+
cd "$SCRIPT_DIR"
32+
wget_command="wget -N https://raw.githubusercontent.com/biolab/orange-hugo/master/scripts/create_widget_catalog.py"
33+
run_command="python create_widget_catalog.py --categories Data,Visualize,Model,Evaluate,Unsupervised --doc visual-programming/source/"
34+
eval "$wget_command"
35+
eval "$run_command"
36+
diff=$(git diff -- widgets.json)
37+
echo "$diff"
38+
if [ -n "$diff" ]
39+
then
40+
echo "Widget catalog is stale. Rebuild it with:"
41+
echo "cd doc"
42+
echo "$wget_command"
43+
echo "$run_command"
44+
echo
45+
echo "$diff"
46+
exit 1
47+
fi

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ requires = [
66
"numpy==1.14.5; python_version=='3.7'",
77
"numpy==1.17.3; python_version=='3.8'",
88
]
9+
10+
build-backend = "setuptools.build_meta"

tox.ini

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
[tox]
2+
envlist =
3+
py{36,37,38}
4+
pylint
5+
build_doc
6+
coverage
7+
add-ons
8+
skip_missing_interpreters = true
9+
isolated_build = true
10+
minversion = 3.6.0
11+
12+
[testenv]
13+
passenv = *
14+
# we MUST changedir to avoid installed being shadowed by working dir
15+
# https://github.com/tox-dev/tox/issues/54
16+
# https://github.com/tox-dev/tox/issues/514
17+
changedir =
18+
{envsitepackagesdir}
19+
setenv =
20+
# Raise deprecations as errors in our tests
21+
ORANGE_DEPRECATIONS_ERROR=y
22+
# Need this otherwise unittest installs a warning filter that overrides
23+
# our desire to have OrangeDeprecationWarnings raised
24+
PYTHONWARNINGS=module
25+
deps =
26+
pyqt5!=5.10,<5.14
27+
pyqtwebengine<5.14
28+
commands_pre =
29+
# Verify installed packages have compatible dependencies
30+
pip check
31+
# freeze environment
32+
pip freeze
33+
commands =
34+
python -m unittest --verbose Orange.tests Orange.widgets.tests
35+
36+
[testenv:coverage]
37+
setenv =
38+
{[testenv]setenv}
39+
# Skip loading of example workflows as that inflates coverage
40+
SKIP_EXAMPLE_WORKFLOWS=True
41+
# set coverage output and project config
42+
COVERAGE_FILE = {toxinidir}/.coverage
43+
COVERAGE_RCFILE = {toxinidir}/.coveragerc
44+
deps =
45+
{[testenv]deps}
46+
coverage
47+
psycopg2-binary
48+
# no wheels for mac
49+
pymssql<3.0;platform_system!='Darwin' and python_version<'3.8'
50+
commands =
51+
coverage run -m unittest --verbose Orange.tests Orange.widgets.tests
52+
coverage combine
53+
coverage report
54+
55+
[testenv:add-ons]
56+
deps =
57+
{[testenv]deps}
58+
Orange3-Educational
59+
Orange3-Geo
60+
Orange3-ImageAnalytics
61+
Orange3-Text
62+
commands =
63+
python -m unittest discover --verbose --start-directory {envsitepackagesdir}/orangecontrib
64+
65+
[testenv:pylint-ci]
66+
changedir = {toxinidir}
67+
skip_install = true
68+
whitelist_externals = bash
69+
deps = pylint
70+
commands =
71+
bash {toxinidir}/.travis/check_pylint_diff
72+
73+
[testenv:build_doc]
74+
changedir = {toxinidir}
75+
usedevelop = true
76+
whitelist_externals = bash
77+
deps =
78+
{[testenv]deps}
79+
-r {toxinidir}/requirements-doc.txt
80+
commands =
81+
bash doc/build_doc.sh

0 commit comments

Comments
 (0)