diff --git a/testing/conftest.py b/testing/conftest.py new file mode 100644 index 000000000..1d32e1174 --- /dev/null +++ b/testing/conftest.py @@ -0,0 +1,8 @@ +import pymol + +pymol.__path__.append(".") +pymol.__path__.append("tests/helpers") + +collect_ignore = [ + "tests/helpers", +] diff --git a/testing/pytest.ini b/testing/pytest.ini index c24fe5bb9..c009d1c89 100644 --- a/testing/pytest.ini +++ b/testing/pytest.ini @@ -1,3 +1,8 @@ [pytest] filterwarnings = ignore::DeprecationWarning +addopts = + --import-mode=importlib +testpaths = tests +python_files = + *.py diff --git a/testing/testing.py b/testing/testing.py index b45047cfe..eea78ba5c 100644 --- a/testing/testing.py +++ b/testing/testing.py @@ -104,8 +104,10 @@ def tupleize_version(strversion): parser.add_argument('filenames', nargs='*', default=[]) parser.add_argument('--out', default=sys.stdout) parser.add_argument('--offline', action='store_true') - parser.add_argument('--no-mmlibs', action='store_true') - parser.add_argument('--no-undo', action='store_true') + parser.add_argument('--no-mmlibs', action='store_true', default=True) + parser.add_argument('--with-mmlibs', action='store_false', dest='no_mmlibs') + parser.add_argument('--no-undo', action='store_true', default=True) + parser.add_argument('--with-undo', action='store_false', dest='no_undo') parser.add_argument('--verbosity', type=int, default=2) have_dash_dash = __file__.startswith(sys.argv[0]) or '--run' in sys.argv @@ -377,8 +379,6 @@ class PyMOLTestCase(PyMOLTestCaseMeta("Base", (unittest.TestCase,), {})): assertEquals = unittest.TestCase.assertEqual assertItemsEqual = unittest.TestCase.assertCountEqual - moddirs = {} - def setUp(self): self.oldcwd = os.getcwd() cmd.reinitialize() @@ -387,7 +387,7 @@ def setUp(self): if cliargs.no_undo: cmd.set('suspend_undo', updates=0) - cwd = self.moddirs[type(self).__module__] + cwd = os.path.dirname(inspect.getfile(type(self))) os.chdir(cwd) cmd.feedback('push') @@ -679,7 +679,6 @@ def run_testfiles(filenames='all', verbosity=2, out=sys.stderr, **kwargs): # hacky: register working directory with test cases dirname = os.path.abspath(os.path.dirname(filename)) - PyMOLTestCase.moddirs[mod.__name__] = dirname suite.addTest(unittest.defaultTestLoader .loadTestsFromModule(mod)) diff --git a/testing/tests/api/importing.py b/testing/tests/api/importing.py index 6e19ac2d8..e302dabc9 100644 --- a/testing/tests/api/importing.py +++ b/testing/tests/api/importing.py @@ -529,7 +529,7 @@ def testLoadPDBQT(self): 0.21, -0.644, -0.644] self.assertArrayEqual(charges, charges_expected, delta=1e-4) - @testing.requires_version('1.8.3.1') + @testing.requires_version('2.6') def testLoadPLY(self): cmd.load(self.datafile("test_PHE_pentamer.ply.gz")) e = cmd.get_extent('test_PHE_pentamer')