Skip to content

Commit 750cabd

Browse files
author
Martin Urban
committed
Add one test to check if the cmd module is working
1 parent fc7ef81 commit 750cabd

File tree

6 files changed

+59
-0
lines changed

6 files changed

+59
-0
lines changed

.github/workflows/build_exe.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,17 @@ jobs:
6262
source .venv/bin/activate
6363
python automations/my_automator.py setup dev-env
6464
python automations/my_automator.py build so
65+
python automations/my_automator.py build wheel
66+
pip install dist/*.whl
6567
python automations/my_automator.py build exe
6668
69+
- name: Run pytest
70+
run: |
71+
source .venv/bin/activate
72+
pip install pytest
73+
cd tests/
74+
pytest
75+
6776
- name: Upload artifact
6877
uses: actions/upload-artifact@v4
6978
with:

.github/workflows/build_wheel.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ jobs:
6262
python automations/my_automator.py build so
6363
python automations/my_automator.py build wheel
6464
65+
- name: Run pytest
66+
run: |
67+
source .venv/bin/activate
68+
pip install pytest
69+
cd tests/
70+
pytest
71+
6572
- name: Upload artifact
6673
uses: actions/upload-artifact@v4
6774
with:

automations/my_automator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import build_macos_wheel
1818
import build_macos_exe
1919
import build_macos_so
20+
import run_pytest
2021
import dev_env
2122

2223

@@ -46,6 +47,10 @@
4647
"func": build_macos_so.build_cmd_module
4748
}
4849
}
50+
},
51+
"test": {
52+
"help": "Runs all tests under the tests/ directory using pytest.",
53+
"func": run_pytest.run_pytest_suite
4954
}
5055
}
5156

automations/run_pytest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import pathlib
2+
import subprocess
3+
4+
import const
5+
6+
7+
def run_pytest_suite():
8+
"""Runs the pytest suite."""
9+
subprocess.run(
10+
[pathlib.Path(const.PROJECT_ROOT_DIR / ".venv/bin/pytest")],
11+
cwd=pathlib.Path(const.PROJECT_ROOT_DIR / "tests")
12+
)

tests/__init__.py

Whitespace-only changes.

tests/test_pymol.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
#A* -------------------------------------------------------------------
3+
#B* This file contains source code for running a simple example
4+
#C* Copyright 2025 by Martin Urban.
5+
#D* -------------------------------------------------------------------
6+
#E* It is unlawful to modify or remove this copyright notice.
7+
#F* -------------------------------------------------------------------
8+
#G* Please see the accompanying LICENSE file for further information.
9+
#H* -------------------------------------------------------------------
10+
#I* Additional authors of this source file include:
11+
#-*
12+
#-*
13+
#-*
14+
#Z* -------------------------------------------------------------------
15+
"""
16+
import pathlib
17+
18+
from pymol import cmd
19+
20+
_FILEPATH = pathlib.Path(__file__).parent
21+
22+
23+
def test_fetch():
24+
cmd.fetch("3bmp")
25+
assert pathlib.Path(_FILEPATH / "3bmp.cif").exists() is True
26+
assert cmd.get_model("3bmp").atom[0].model == "3bmp"

0 commit comments

Comments
 (0)