From 633361c3e79f03dfc3766e89e31f4b11a8786d6c Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Sun, 22 Jun 2025 20:44:31 +0200 Subject: [PATCH 1/5] Introduce pytest Co-authored-by: Pedro Lacerda --- pytest.ini | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..1aa9fc2 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,8 @@ +[pytest] +addopts = + --ignore-glob=_* + --import-mode=importlib +pythonpath = . +python_files = *.py +python_functions = test_* +norecursedirs = examples files_for_examples modules plugins From decc441e09b63d60ac4dfdf11914450cefc28e0b Mon Sep 17 00:00:00 2001 From: Pedro Lacerda Date: Sun, 22 Jun 2025 03:17:28 -0300 Subject: [PATCH 2/5] Example test --- findseq.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/findseq.py b/findseq.py index 07d73a5..8cbcbb6 100644 --- a/findseq.py +++ b/findseq.py @@ -203,3 +203,11 @@ def checkParams(needle, haystack, selName, het, matchMode): print("Error: selName was not a string.") return False return True + + +def test_findseq(): + cmd.fab('ACDEFG', 'm1') + cmd.fab('HIKLMN', 'm2') + cmd.do('findseq DEF, *, foundSeq') + assert cmd.count_atoms("foundSeq and m1") == 47 + assert cmd.count_atoms("foundSeq and m2") == 0 From 8b032f8d9e441566a05798fabfb6d2a1fa56771a Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Sun, 22 Jun 2025 20:53:02 +0200 Subject: [PATCH 3/5] Github actions --- .github/workflows/ci.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..52b7d07 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: CI + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - uses: mamba-org/setup-micromamba@v2 + with: + generate-run-shell: true + environment-name: ci + create-args: >- + pillow + pymol-open-source + pyopengl + pytest + requests + + - name: Test + run: python3 -m pytest -v + shell: micromamba-shell {0} From fc23a4bb0ad1f0763925ec97a5aad89744648dec Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Sun, 22 Jun 2025 21:08:19 +0200 Subject: [PATCH 4/5] test_findseq: Call cmd.reinitialize() --- findseq.py | 1 + 1 file changed, 1 insertion(+) diff --git a/findseq.py b/findseq.py index 8cbcbb6..0672c02 100644 --- a/findseq.py +++ b/findseq.py @@ -206,6 +206,7 @@ def checkParams(needle, haystack, selName, het, matchMode): def test_findseq(): + cmd.reinitialize() cmd.fab('ACDEFG', 'm1') cmd.fab('HIKLMN', 'm2') cmd.do('findseq DEF, *, foundSeq') From 8da682d13002968e53654e9b0d9113c6ed131442 Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Sun, 22 Jun 2025 21:19:55 +0200 Subject: [PATCH 5/5] Pytest ignore gendocs.py --- pytest.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/pytest.ini b/pytest.ini index 1aa9fc2..7095195 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,6 +1,7 @@ [pytest] addopts = --ignore-glob=_* + --ignore-glob=gendocs.py --import-mode=importlib pythonpath = . python_files = *.py