Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running all tests with pytest, make --no-mmlibs --no-undo the default #333

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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