From 7371f183c39e4804bbd7736f073a73dc4923ea39 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Mon, 11 Dec 2023 16:14:02 -0500 Subject: [PATCH] Started adding basic automated tests --- .github/workflows/test.yml | 41 ++++++++++++++++++++++++++++++++++++++ .gitignore | 1 + .vscode/settings.json | 11 ++++++++++ gcft.py | 8 +------- gcft_ui/main_window.py | 6 ++++++ pytest.ini | 3 +++ requirements_full.txt | 3 +++ test/test_gui.py | 4 ++++ 8 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 pytest.ini create mode 100644 test/test_gui.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..c60bbbd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +name: Test + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + strategy: + matrix: + include: + - name: Windows + os: windows-latest + - name: MacOS + os: macos-latest + - name: Linux + os: ubuntu-20.04 + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements_full.txt + - name: Test with pytest + run: | + pip install pytest pytest-cov + pytest test --cov=gcft_ui --cov=gclib --cov-report=html + - name: Upload Coverage Report + uses: actions/upload-artifact@v3 + with: + name: gcft-htmlcov-${{ matrix.os }} + path: htmlcov diff --git a/.gitignore b/.gitignore index 662de83..21a8553 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ settings.txt /.venv profileresults*.txt profileresults*.prof +.coverage diff --git a/.vscode/settings.json b/.vscode/settings.json index 097cff0..bec26aa 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,4 +12,15 @@ "search.exclude": { "PyJ3DUltra": true, }, + "python.analysis.exclude": [ + "PyJ3DUltra" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true, + "python.testing.pytestArgs": [ + "test", + "--cov=gcft_ui", + "--cov=gclib", + "--cov-report=html", + ], } \ No newline at end of file diff --git a/gcft.py b/gcft.py index 4e336a7..62db8a1 100644 --- a/gcft.py +++ b/gcft.py @@ -1,17 +1,11 @@ #!/usr/bin/python3 +import sys import traceback from PySide6.QtGui import * from PySide6.QtCore import * from PySide6.QtWidgets import * -import sys - -sys.path.insert(0, "./gclib") -sys.path.insert(0, "./PyJ3DUltra/build") -sys.path.insert(0, "./PyJ3DUltra/build/Release") -sys.path.insert(0, "./PyJ3DUltra/build/Debug") - from gcft_ui.main_window import GCFTWindow def signal_handler(sig, frame): diff --git a/gcft_ui/main_window.py b/gcft_ui/main_window.py index 3096d28..6ea3f6a 100644 --- a/gcft_ui/main_window.py +++ b/gcft_ui/main_window.py @@ -1,4 +1,5 @@ +import sys import os import re import traceback @@ -8,6 +9,11 @@ from PySide6.QtCore import * from PySide6.QtWidgets import * +sys.path.insert(0, "./gclib") +sys.path.insert(0, "./PyJ3DUltra/build") +sys.path.insert(0, "./PyJ3DUltra/build/Release") +sys.path.insert(0, "./PyJ3DUltra/build/Debug") + from gclib import fs_helpers as fs from gcft_ui.uic.ui_main import Ui_MainWindow from gcft_ui.gcft_common import GCFTThread, GCFTProgressDialog diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..b6a8cfe --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +testpaths = + test diff --git a/requirements_full.txt b/requirements_full.txt index ca5ba77..fd394ad 100644 --- a/requirements_full.txt +++ b/requirements_full.txt @@ -7,3 +7,6 @@ numpy~=1.26.0 PyOpenGL>=3.1.0,<3.1.7 pyrr==0.10.3 PyInstaller~=6.2.0 +pytest~=7.4.0 +pytest-cov~=4.1.0 +pytest-qt~=4.2.0 diff --git a/test/test_gui.py b/test/test_gui.py new file mode 100644 index 0000000..d9e1b94 --- /dev/null +++ b/test/test_gui.py @@ -0,0 +1,4 @@ + +def test_gui_launches(qtbot): + from gcft_ui.main_window import GCFTWindow + window = GCFTWindow()