Skip to content

Commit 1786167

Browse files
committed
TestComputeCD: do not mock matplotlib
1 parent d5d1665 commit 1786167

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

Orange/tests/test_evaluation_scoring.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# Test methods with long descriptive names can omit docstrings
22
# pylint: disable=missing-docstring
33

4-
import sys
5-
import contextlib
64
import unittest
7-
from unittest.mock import Mock
85
import numpy as np
96

107
from Orange.data import DiscreteVariable, ContinuousVariable, Domain
@@ -337,23 +334,9 @@ def test_compute_CD(self):
337334
cd = scoring.compute_CD(avranks, 30, test="bonferroni-dunn")
338335
np.testing.assert_almost_equal(cd, 0.798)
339336

340-
@contextlib.contextmanager
341-
def mock_module(name):
342-
if not name in sys.modules:
343-
try:
344-
sys.modules[name] = Mock()
345-
yield
346-
finally:
347-
del sys.modules[name]
348-
else:
349-
yield
350-
351337
# Do what you will, just don't crash
352-
with mock_module("matplotlib"), \
353-
mock_module("matplotlib.pyplot"), \
354-
mock_module("matplotlib.backends.backend_agg"):
355-
scoring.graph_ranks(avranks, "abcd", cd)
356-
scoring.graph_ranks(avranks, "abcd", cd, cdmethod=0)
338+
scoring.graph_ranks(avranks, "abcd", cd)
339+
scoring.graph_ranks(avranks, "abcd", cd, cdmethod=0)
357340

358341

359342
class TestLogLoss(unittest.TestCase):

0 commit comments

Comments
 (0)