Skip to content

Commit

Permalink
Support running all tests with pytest, make --no-mmlibs --no-undo the…
Browse files Browse the repository at this point in the history
… default (schrodinger#333)

* Support running all tests with pytest

* Make --no-mmlibs --no-undo the default

These tests seem unsupported by modern PyMOL versions (like 2.5.6), see
schrodinger/pymol-testing#9

Add `--with-mmlibs` and `--with-undo` options to enable these tests.

* Require PyMOL 2.6 for testLoadPLY
  • Loading branch information
speleo3 authored Jan 31, 2024
1 parent 92d39a1 commit 9dcb209
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
8 changes: 8 additions & 0 deletions testing/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import pymol

pymol.__path__.append(".")
pymol.__path__.append("tests/helpers")

collect_ignore = [
"tests/helpers",
]
5 changes: 5 additions & 0 deletions testing/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[pytest]
filterwarnings =
ignore::DeprecationWarning
addopts =
--import-mode=importlib
testpaths = tests
python_files =
*.py
11 changes: 5 additions & 6 deletions testing/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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')
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion testing/tests/api/importing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 9dcb209

Please sign in to comment.