From 1d3b911df396d36ef01e51731667792a4e9d44c6 Mon Sep 17 00:00:00 2001 From: ALescoulie Date: Mon, 2 Aug 2021 23:03:34 -0700 Subject: [PATCH] Replace relative imports in tests --- mdpow/tests/test_Gsolv.py | 2 +- mdpow/tests/test_analysis.py | 13 +++---------- mdpow/tests/test_analysis_alchemlyb.py | 13 +++---------- mdpow/tests/test_emin.py | 2 +- mdpow/tests/test_equilibration_script.py | 2 +- mdpow/tests/test_fep_script.py | 2 +- mdpow/tests/test_version.py | 2 +- 7 files changed, 11 insertions(+), 25 deletions(-) diff --git a/mdpow/tests/test_Gsolv.py b/mdpow/tests/test_Gsolv.py index 86ffe535..c3e97a9c 100644 --- a/mdpow/tests/test_Gsolv.py +++ b/mdpow/tests/test_Gsolv.py @@ -1,4 +1,4 @@ -import tempdir as td +import mdpow.tests.tempdir as td import os import pybol diff --git a/mdpow/tests/test_analysis.py b/mdpow/tests/test_analysis.py index 8b4179a7..5ab4cacb 100644 --- a/mdpow/tests/test_analysis.py +++ b/mdpow/tests/test_analysis.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import os.path import sys @@ -11,10 +9,9 @@ from numpy.testing import assert_array_almost_equal -from six.moves import cPickle as pickle +import _pickle as pickle import numkit -import mdpow.fep from pkg_resources import resource_filename RESOURCES = py.path.local(resource_filename(__name__, 'testing_resources')) @@ -67,12 +64,8 @@ def fep_benzene_directory(tmpdir_factory): class TestAnalyze(object): def get_Gsolv(self, pth): gsolv = pth.join("FEP", "water", "Gsolv.fep") - if sys.version_info.major == 2: - G = pickle.load(gsolv.open()) - elif sys.version_info.major == 3: - # Needed to read old pickle files - with open(gsolv, 'rb') as f: - G = pickle.load(f, encoding='latin1') + with open(gsolv, 'rb') as f: + G = pickle.load(f, encoding='latin1') # patch paths G.basedir = pth.strpath G.filename = gsolv.strpath diff --git a/mdpow/tests/test_analysis_alchemlyb.py b/mdpow/tests/test_analysis_alchemlyb.py index fecd6738..a5c0c0a7 100644 --- a/mdpow/tests/test_analysis_alchemlyb.py +++ b/mdpow/tests/test_analysis_alchemlyb.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import os.path import sys @@ -12,7 +10,7 @@ from numpy.testing import assert_array_almost_equal import pandas -from six.moves import cPickle as pickle +import _pickle as pickle import mdpow.fep @@ -67,13 +65,8 @@ def fep_benzene_directory(tmpdir_factory): class TestAnalyze(object): def get_Gsolv(self, pth): gsolv = pth.join("FEP", "water", "Gsolv.fep") - # Needed to load old pickle files in python 3 - if sys.version_info.major >= 3: - with open(gsolv, 'rb') as f: - G = pickle.load(f, encoding='latin1') - # patch paths - elif sys.version_info.major == 2: - G = pickle.load(gsolv.open()) + with open(gsolv, 'rb') as f: + G = pickle.load(f, encoding='latin1') G.basedir = pth.strpath G.filename = gsolv.strpath diff --git a/mdpow/tests/test_emin.py b/mdpow/tests/test_emin.py index 615b308b..9fc0aa6f 100644 --- a/mdpow/tests/test_emin.py +++ b/mdpow/tests/test_emin.py @@ -1,4 +1,4 @@ -import tempdir as td +import mdpow.tests.tempdir as td import mdpow.equil import os diff --git a/mdpow/tests/test_equilibration_script.py b/mdpow/tests/test_equilibration_script.py index 23c5a6df..3f67dcd7 100644 --- a/mdpow/tests/test_equilibration_script.py +++ b/mdpow/tests/test_equilibration_script.py @@ -1,4 +1,4 @@ -import tempdir as td +import mdpow.tests.tempdir as td import os.path import pybol diff --git a/mdpow/tests/test_fep_script.py b/mdpow/tests/test_fep_script.py index 191751e8..5d89a716 100644 --- a/mdpow/tests/test_fep_script.py +++ b/mdpow/tests/test_fep_script.py @@ -1,4 +1,4 @@ -import tempdir as td +import mdpow.tests.tempdir as td import os import pybol diff --git a/mdpow/tests/test_version.py b/mdpow/tests/test_version.py index 1f7357bc..187f27d4 100644 --- a/mdpow/tests/test_version.py +++ b/mdpow/tests/test_version.py @@ -7,7 +7,7 @@ def version(): return mdpow.__version__ def test_version_string(version): - assert isinstance(version, six.string_types) + assert isinstance(version, str) def test_version(version): # generic non-empty check because versioneer can provide different