From 661c7ffbecff5c9da9757db6627bcb2cf1aab138 Mon Sep 17 00:00:00 2001 From: Bobby Tomlinson Date: Thu, 22 Jan 2026 12:57:27 -0500 Subject: [PATCH 1/4] Create new tests folder structure --- tests/integration/__init__.py | 0 tests/unit/__init__.py | 0 tests/{ => unit}/test_load.py | 0 tests/{ => unit}/test_main.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/integration/__init__.py create mode 100644 tests/unit/__init__.py rename tests/{ => unit}/test_load.py (100%) rename tests/{ => unit}/test_main.py (100%) diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_load.py b/tests/unit/test_load.py similarity index 100% rename from tests/test_load.py rename to tests/unit/test_load.py diff --git a/tests/test_main.py b/tests/unit/test_main.py similarity index 100% rename from tests/test_main.py rename to tests/unit/test_main.py From 73c18e61c87735fabbcd5ee212241edbf41525c7 Mon Sep 17 00:00:00 2001 From: Bobby Tomlinson Date: Thu, 22 Jan 2026 15:14:56 -0500 Subject: [PATCH 2/4] Move tests outside package and organize test infrastructure --- LabGym/tests/__init__.py | 0 LabGym/tests/tmp.pylint/.gitkeep | 0 LabGym/tests/pytest.ini => pytest.ini | 7 +++ tests/conftest.py | 45 ++++++++++++++++++ {LabGym/tests => tests}/coveragerc | 0 {LabGym/tests => tests/linting}/INIT.sh | 2 +- {LabGym/tests => tests/linting}/pylint.sh | 2 +- {LabGym/tests => tests/linting}/pylintrc | 0 {LabGym/tests => tests/linting}/pylintrc- | 0 .../notes}/Notes.importtime.txt | 0 ...es.opencv-python-and-coverage-warnings.txt | 0 .../tests => tests/notes}/Notes.pytest.txt | 0 .../tests => tests/notes}/pylint.Notes.txt | 0 {LabGym/tests => tests/unit}/exitstatus.py | 0 {LabGym/tests => tests/unit}/test___main__.py | 0 .../unit}/test_central_logging.py | 0 {LabGym/tests => tests/unit}/test_config.py | 0 .../tests => tests/unit}/test_config/bad.yaml | Bin .../tests => tests/unit}/test_myargparse.py | 0 .../tests => tests/unit}/test_mylogging.py | 0 .../unit}/test_mypkg_resources.py | 0 {LabGym/tests => tests/unit}/test_mywx.py | 0 {LabGym/tests => tests/unit}/test_pkghash.py | 0 {LabGym/tests => tests/unit}/test_probes.py | 0 .../unit}/test_probes/cacert.fouled.pem | 0 .../unit}/test_probes/cacert.pem | 0 .../tests => tests/unit}/test_registration.py | 0 .../unit}/test_registration/registration.yaml | 0 .../unit}/test_userdata_survey.py | 0 29 files changed, 54 insertions(+), 2 deletions(-) delete mode 100644 LabGym/tests/__init__.py delete mode 100644 LabGym/tests/tmp.pylint/.gitkeep rename LabGym/tests/pytest.ini => pytest.ini (68%) create mode 100644 tests/conftest.py rename {LabGym/tests => tests}/coveragerc (100%) rename {LabGym/tests => tests/linting}/INIT.sh (92%) rename {LabGym/tests => tests/linting}/pylint.sh (99%) rename {LabGym/tests => tests/linting}/pylintrc (100%) rename {LabGym/tests => tests/linting}/pylintrc- (100%) rename {LabGym/tests => tests/notes}/Notes.importtime.txt (100%) rename {LabGym/tests => tests/notes}/Notes.opencv-python-and-coverage-warnings.txt (100%) rename {LabGym/tests => tests/notes}/Notes.pytest.txt (100%) rename {LabGym/tests => tests/notes}/pylint.Notes.txt (100%) rename {LabGym/tests => tests/unit}/exitstatus.py (100%) rename {LabGym/tests => tests/unit}/test___main__.py (100%) rename {LabGym/tests => tests/unit}/test_central_logging.py (100%) rename {LabGym/tests => tests/unit}/test_config.py (100%) rename {LabGym/tests => tests/unit}/test_config/bad.yaml (100%) rename {LabGym/tests => tests/unit}/test_myargparse.py (100%) rename {LabGym/tests => tests/unit}/test_mylogging.py (100%) rename {LabGym/tests => tests/unit}/test_mypkg_resources.py (100%) rename {LabGym/tests => tests/unit}/test_mywx.py (100%) rename {LabGym/tests => tests/unit}/test_pkghash.py (100%) rename {LabGym/tests => tests/unit}/test_probes.py (100%) rename {LabGym/tests => tests/unit}/test_probes/cacert.fouled.pem (100%) rename {LabGym/tests => tests/unit}/test_probes/cacert.pem (100%) rename {LabGym/tests => tests/unit}/test_registration.py (100%) rename {LabGym/tests => tests/unit}/test_registration/registration.yaml (100%) rename {LabGym/tests => tests/unit}/test_userdata_survey.py (100%) diff --git a/LabGym/tests/__init__.py b/LabGym/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/LabGym/tests/tmp.pylint/.gitkeep b/LabGym/tests/tmp.pylint/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/LabGym/tests/pytest.ini b/pytest.ini similarity index 68% rename from LabGym/tests/pytest.ini rename to pytest.ini index 385a3fef..f75122ee 100644 --- a/LabGym/tests/pytest.ini +++ b/pytest.ini @@ -1,5 +1,12 @@ # pytest.ini [pytest] +testpaths = tests + +markers = + slow: marks tests as slow + integration: markts integration tests + gui: marks tests requiring wx + # Avoid two coverage warnings from detectron2's import of cv2. # (see Notes.opencv-python-and-coverage-warnings.txt) filterwarnings = diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..a4e59139 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,45 @@ +""" +/tests/conftest.py + +Shared pytest fixtures for LabGym tests +""" + +# Standard library imports +import sys + +# Related third party imports +import pytest + +@pytest.fixture(scope="session") +def wx_app(): + from LabGym.ui.gui import wxutils + import wx + app = wx.App() + yield app + + +@pytest.fixture +def mock_argv(monkeypatch): + monkeypatch.setattr(sys, 'argv', ['LabGym']) + + +@pytest.fixture +def sample_greyscale_frame(): + import numpy as np + import cv2 + frame = np.full((100, 100), 200, dtype = np.uint8) + cv2.circle(frame, (50, 50), 15, 50, -1) + return frame + +@pytest.fixture +def sample_video_frames(): + import numpy as np + import cv2 + frames = [] + + for i in range(60): + frame = np.full((100, 100), 200, dtype = np.uint8) + cv2.circle(frame, (20 + i % 60, 50), 15, 50, -1) + frames.append(frame) + + return frames \ No newline at end of file diff --git a/LabGym/tests/coveragerc b/tests/coveragerc similarity index 100% rename from LabGym/tests/coveragerc rename to tests/coveragerc diff --git a/LabGym/tests/INIT.sh b/tests/linting/INIT.sh similarity index 92% rename from LabGym/tests/INIT.sh rename to tests/linting/INIT.sh index 1475db15..50df101c 100644 --- a/LabGym/tests/INIT.sh +++ b/tests/linting/INIT.sh @@ -10,7 +10,7 @@ IS_VENV () { [ -n "$VIRTUAL_ENV+1" ]; } # works in sh, bash, and zsh AWK () { awk "$@"; } -PYFILES=$(cd .. && echo *.py) +PYFILES=$(cd ../../LabGym && echo *.py) # printf "%s: %s\n" "\$PYFILES" "$PYFILES" return diff --git a/LabGym/tests/pylint.sh b/tests/linting/pylint.sh similarity index 99% rename from LabGym/tests/pylint.sh rename to tests/linting/pylint.sh index 373b2ed6..2b1ebded 100644 --- a/LabGym/tests/pylint.sh +++ b/tests/linting/pylint.sh @@ -10,7 +10,7 @@ source INIT.sh -PYFILES=$(echo ../*.py ../mywx/*.py) +PYFILES=$(echo ../../LabGym/*.py ../../LabGym/mywx/*.py) OP=pylint # default OP while [ $# -gt 0 ]; do diff --git a/LabGym/tests/pylintrc b/tests/linting/pylintrc similarity index 100% rename from LabGym/tests/pylintrc rename to tests/linting/pylintrc diff --git a/LabGym/tests/pylintrc- b/tests/linting/pylintrc- similarity index 100% rename from LabGym/tests/pylintrc- rename to tests/linting/pylintrc- diff --git a/LabGym/tests/Notes.importtime.txt b/tests/notes/Notes.importtime.txt similarity index 100% rename from LabGym/tests/Notes.importtime.txt rename to tests/notes/Notes.importtime.txt diff --git a/LabGym/tests/Notes.opencv-python-and-coverage-warnings.txt b/tests/notes/Notes.opencv-python-and-coverage-warnings.txt similarity index 100% rename from LabGym/tests/Notes.opencv-python-and-coverage-warnings.txt rename to tests/notes/Notes.opencv-python-and-coverage-warnings.txt diff --git a/LabGym/tests/Notes.pytest.txt b/tests/notes/Notes.pytest.txt similarity index 100% rename from LabGym/tests/Notes.pytest.txt rename to tests/notes/Notes.pytest.txt diff --git a/LabGym/tests/pylint.Notes.txt b/tests/notes/pylint.Notes.txt similarity index 100% rename from LabGym/tests/pylint.Notes.txt rename to tests/notes/pylint.Notes.txt diff --git a/LabGym/tests/exitstatus.py b/tests/unit/exitstatus.py similarity index 100% rename from LabGym/tests/exitstatus.py rename to tests/unit/exitstatus.py diff --git a/LabGym/tests/test___main__.py b/tests/unit/test___main__.py similarity index 100% rename from LabGym/tests/test___main__.py rename to tests/unit/test___main__.py diff --git a/LabGym/tests/test_central_logging.py b/tests/unit/test_central_logging.py similarity index 100% rename from LabGym/tests/test_central_logging.py rename to tests/unit/test_central_logging.py diff --git a/LabGym/tests/test_config.py b/tests/unit/test_config.py similarity index 100% rename from LabGym/tests/test_config.py rename to tests/unit/test_config.py diff --git a/LabGym/tests/test_config/bad.yaml b/tests/unit/test_config/bad.yaml similarity index 100% rename from LabGym/tests/test_config/bad.yaml rename to tests/unit/test_config/bad.yaml diff --git a/LabGym/tests/test_myargparse.py b/tests/unit/test_myargparse.py similarity index 100% rename from LabGym/tests/test_myargparse.py rename to tests/unit/test_myargparse.py diff --git a/LabGym/tests/test_mylogging.py b/tests/unit/test_mylogging.py similarity index 100% rename from LabGym/tests/test_mylogging.py rename to tests/unit/test_mylogging.py diff --git a/LabGym/tests/test_mypkg_resources.py b/tests/unit/test_mypkg_resources.py similarity index 100% rename from LabGym/tests/test_mypkg_resources.py rename to tests/unit/test_mypkg_resources.py diff --git a/LabGym/tests/test_mywx.py b/tests/unit/test_mywx.py similarity index 100% rename from LabGym/tests/test_mywx.py rename to tests/unit/test_mywx.py diff --git a/LabGym/tests/test_pkghash.py b/tests/unit/test_pkghash.py similarity index 100% rename from LabGym/tests/test_pkghash.py rename to tests/unit/test_pkghash.py diff --git a/LabGym/tests/test_probes.py b/tests/unit/test_probes.py similarity index 100% rename from LabGym/tests/test_probes.py rename to tests/unit/test_probes.py diff --git a/LabGym/tests/test_probes/cacert.fouled.pem b/tests/unit/test_probes/cacert.fouled.pem similarity index 100% rename from LabGym/tests/test_probes/cacert.fouled.pem rename to tests/unit/test_probes/cacert.fouled.pem diff --git a/LabGym/tests/test_probes/cacert.pem b/tests/unit/test_probes/cacert.pem similarity index 100% rename from LabGym/tests/test_probes/cacert.pem rename to tests/unit/test_probes/cacert.pem diff --git a/LabGym/tests/test_registration.py b/tests/unit/test_registration.py similarity index 100% rename from LabGym/tests/test_registration.py rename to tests/unit/test_registration.py diff --git a/LabGym/tests/test_registration/registration.yaml b/tests/unit/test_registration/registration.yaml similarity index 100% rename from LabGym/tests/test_registration/registration.yaml rename to tests/unit/test_registration/registration.yaml diff --git a/LabGym/tests/test_userdata_survey.py b/tests/unit/test_userdata_survey.py similarity index 100% rename from LabGym/tests/test_userdata_survey.py rename to tests/unit/test_userdata_survey.py From 016caf06993fb889b75a2eccbe32b6eace48f408 Mon Sep 17 00:00:00 2001 From: Bobby Tomlinson Date: Thu, 22 Jan 2026 15:48:51 -0500 Subject: [PATCH 3/4] PR bug fix: install 'coverage' via noxfile.py --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index e960e264..aefc4dd3 100644 --- a/noxfile.py +++ b/noxfile.py @@ -52,7 +52,7 @@ def tests(session:nox.Session): # package and test dependencies session.install("-e", ".") - session.install("pytest") + session.install("pytest, coverage") session.run("pytest", "-q") From 56be27779d141fc6175922bf1fdae18725800f96 Mon Sep 17 00:00:00 2001 From: Bobby Tomlinson Date: Thu, 22 Jan 2026 15:56:37 -0500 Subject: [PATCH 4/4] PR bug fix: typo --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index aefc4dd3..6319fed8 100644 --- a/noxfile.py +++ b/noxfile.py @@ -52,7 +52,7 @@ def tests(session:nox.Session): # package and test dependencies session.install("-e", ".") - session.install("pytest, coverage") + session.install("pytest", "coverage") session.run("pytest", "-q")