diff --git a/Orange/data/tests/test_pandas.py b/Orange/data/tests/test_pandas.py index b6bbd80a97..cc1a7bc03a 100644 --- a/Orange/data/tests/test_pandas.py +++ b/Orange/data/tests/test_pandas.py @@ -5,7 +5,6 @@ import numpy as np import pandas as pd -import pytz from scipy.sparse import csr_matrix import scipy.sparse as sp @@ -14,6 +13,10 @@ from Orange.data.pandas_compat import OrangeDataFrame, table_from_frame from Orange.data.tests.test_variable import TestTimeVariable +if pd.__version__ < "2": + import pytz +else: + pytz = None class TestPandasCompat(unittest.TestCase): def test_table_from_frame(self): @@ -307,7 +310,7 @@ def test_table_from_frame_timezones(self): ] ) table = table_from_frame(df) - tz = pytz.utc if pd.__version__ < "2" else timezone.utc + tz = pytz.utc if pytz is not None else timezone.utc self.assertEqual(tz, table.domain.variables[0].timezone) np.testing.assert_equal( table.X, @@ -326,7 +329,7 @@ def test_table_from_frame_timezones(self): ] ) table = table_from_frame(df) - tz = pytz.FixedOffset(60) if pd.__version__ < "2" else \ + tz = pytz.FixedOffset(60) if pytz is not None else \ timezone(timedelta(seconds=3600)) self.assertEqual(tz, table.domain.variables[0].timezone) np.testing.assert_equal( @@ -345,12 +348,6 @@ def test_table_from_frame_timezones(self): [np.nan], ] ) - table = table_from_frame(df) - self.assertEqual(pytz.timezone("CET"), table.domain.variables[0].timezone) - # Testing the table was removed because a change in pytz broke it: - # treatment of DST has changed, so test were off by an hour, - # while time zones before ~1930 seem to be off by 42 minutes - # We could fix this, but prefer not to test pytz regressions. df = pd.DataFrame( [ @@ -360,7 +357,7 @@ def test_table_from_frame_timezones(self): ] ) table = table_from_frame(df) - tz = pytz.utc if pd.__version__ < "2" else timezone.utc + tz = pytz.utc if pytz is not None else timezone.utc self.assertEqual(tz, table.domain.variables[0].timezone) np.testing.assert_equal( table.X,