diff --git a/Orange/canvas/application/canvasmain.py b/Orange/canvas/application/canvasmain.py index ed2534aceb0..c67f5ac7497 100644 --- a/Orange/canvas/application/canvasmain.py +++ b/Orange/canvas/application/canvasmain.py @@ -22,13 +22,14 @@ Qt, QEvent, QSize, QUrl, QTimer, QFile, QByteArray, QSettings, QT_VERSION ) -if QT_VERSION < 0x50500: +try: + from AnyQt.QtWebEngineWidgets import QWebEngineView + USE_WEB_ENGINE = True +except ImportError: from AnyQt.QtWebKitWidgets import QWebView from AnyQt.QtNetwork import QNetworkDiskCache USE_WEB_ENGINE = False -else: - from PyQt5.QtWebEngineWidgets import QWebEngineView - USE_WEB_ENGINE = True + from AnyQt.QtCore import pyqtProperty as Property diff --git a/Orange/tests/sql/base.py b/Orange/tests/sql/base.py index c8e63e7c7d1..b1876a89d71 100644 --- a/Orange/tests/sql/base.py +++ b/Orange/tests/sql/base.py @@ -7,8 +7,6 @@ import Orange from Orange.data.sql.table import SqlTable -from Orange.data.sql.backend.postgres import Psycopg2Backend -from psycopg2.pool import ThreadedConnectionPool def sql_test(f): @@ -150,6 +148,9 @@ def assertDictContainsSubset(self, subset, dictionary, msg=None): class PostgresTest(unittest.TestCase): @classmethod def setUpClass(cls): + from psycopg2.pool import ThreadedConnectionPool + from Orange.data.sql.backend.postgres import Psycopg2Backend + Psycopg2Backend.connection_pool = \ ThreadedConnectionPool(1, 1, **connection_params()) cls.backend = Psycopg2Backend(connection_params()) @@ -157,6 +158,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): + from Orange.data.sql.backend.postgres import Psycopg2Backend Psycopg2Backend.connection_pool.closeall() Psycopg2Backend.connection_pool = None @@ -166,6 +168,7 @@ def create_sql_table(self, data, columns=None): @contextlib.contextmanager def sql_table_from_data(self, data, guess_values=True): + from Orange.data.sql.backend.postgres import Psycopg2Backend assert Psycopg2Backend.connection_pool is not None table_name = self._create_sql_table(data) diff --git a/Orange/tests/sql/test_misc.py b/Orange/tests/sql/test_misc.py index 29a9b46fd7a..2f30442002f 100644 --- a/Orange/tests/sql/test_misc.py +++ b/Orange/tests/sql/test_misc.py @@ -2,12 +2,20 @@ Please note that such use is deprecated. """ +import unittest + from Orange.data.sql.table import SqlTable from Orange.preprocess import Discretize from Orange.preprocess.discretize import EqualFreq from Orange.tests.sql.base import PostgresTest -from Orange.widgets.visualize.owmosaic import get_conditional_distribution -from Orange.widgets.visualize.utils.lac import create_sql_contingency, get_bin_centers +try: + from Orange.widgets.visualize.owmosaic import get_conditional_distribution + from Orange.widgets.visualize.utils.lac import \ + create_sql_contingency, get_bin_centers +except ImportError: + no_widgets = True +else: + no_widgets = False class MiscSqlTests(PostgresTest): @@ -16,12 +24,14 @@ def test_discretization(self): sepal_length = iris.domain["sepal length"] EqualFreq(n=4)(iris, sepal_length) + @unittest.skipIf(no_widgets, "Cannot import widgets") def test_get_conditional_distribution(self): iris = SqlTable(self.conn, self.iris, inspect_values=True) sepal_length = iris.domain["sepal length"] get_conditional_distribution(iris, [sepal_length]) get_conditional_distribution(iris, list(iris.domain)) + @unittest.skipIf(no_widgets, "Cannot import widgets") def test_create_sql_contingency(self): iris = SqlTable(self.conn, self.iris, inspect_values=True) d_iris = Discretize()(iris) diff --git a/Orange/tests/test_manifold.py b/Orange/tests/test_manifold.py index cb41424bb7b..6969f87deed 100644 --- a/Orange/tests/test_manifold.py +++ b/Orange/tests/test_manifold.py @@ -56,7 +56,8 @@ def __lle_test_helper(self, data, n_com): lle = lle(data) ltsa = LocallyLinearEmbedding(n_neighbors=5, n_components=n_com, - method="ltsa") + method="ltsa", + eigen_solver="dense") ltsa = ltsa(data) hessian = LocallyLinearEmbedding(n_neighbors=15, n_components=n_com, diff --git a/Orange/widgets/data/tests/test_owfile.py b/Orange/widgets/data/tests/test_owfile.py index 8fae90a8318..56099a00243 100644 --- a/Orange/widgets/data/tests/test_owfile.py +++ b/Orange/widgets/data/tests/test_owfile.py @@ -10,7 +10,7 @@ from Orange.widgets.data.owfile import OWFile from Orange.widgets.tests.base import WidgetTest -TITANIC_URL = path.join(path.dirname(Orange.__file__), 'datasets', 'titanic.tab') +TITANIC_PATH = path.join(path.dirname(Orange.__file__), 'datasets', 'titanic.tab') class TestOWFile(WidgetTest): @@ -22,17 +22,17 @@ def setUp(self): self.widget = self.create_widget(OWFile) def test_dragEnterEvent_accepts_urls(self): - event = self._drag_enter_event(TITANIC_URL) + event = self._drag_enter_event(QUrl.fromLocalFile(TITANIC_PATH)) self.widget.dragEnterEvent(event) self.assertTrue(event.isAccepted()) def test_dragEnterEvent_skips_osx_file_references(self): - event = self._drag_enter_event('/.file/id=12345') + event = self._drag_enter_event(QUrl.fromLocalFile('/.file/id=12345')) self.widget.dragEnterEvent(event) self.assertFalse(event.isAccepted()) def test_dragEnterEvent_skips_usupported_files(self): - event = self._drag_enter_event('file.unsupported') + event = self._drag_enter_event(QUrl.fromLocalFile('file.unsupported')) self.widget.dragEnterEvent(event) self.assertFalse(event.isAccepted()) @@ -48,11 +48,11 @@ def test_dropEvent_selects_file(self): self.widget.load_data = Mock() self.widget.source = OWFile.URL - event = self._drop_event(TITANIC_URL) + event = self._drop_event(QUrl.fromLocalFile(TITANIC_PATH)) self.widget.dropEvent(event) self.assertEqual(self.widget.source, OWFile.LOCAL_FILE) - self.assertEqual(self.widget.last_path(), TITANIC_URL) + self.assertTrue(path.samefile(self.widget.last_path(), TITANIC_PATH)) self.widget.load_data.assert_called_with() def _drop_event(self, url):