From 29e48e284c27407b12ad434f889c73fd029f16ba Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Wed, 18 Sep 2024 18:01:51 +0200 Subject: [PATCH] Adding pytest to drone ci --- ci/drone.yml | 26 +++++--------------------- tests/python/test_helper.py | 9 ++++++--- tests/python/test_pyjs.py | 2 ++ 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/ci/drone.yml b/ci/drone.yml index 3bcf9f2..de4165e 100644 --- a/ci/drone.yml +++ b/ci/drone.yml @@ -11,35 +11,19 @@ steps: commands: - git submodule update --init --recursive -- name: Linux test - image: ad5001/ubuntu-pyside6-xvfb:jammy-6.6.1 +- name: Tests + image: ad5001/ubuntu-pyside6-xvfb:noble-6.7.2 commands: + - pytest --cov --cov-report term-missing - xvfb-run python3 run.py --test-build --no-check-for-updates - xvfb-run python3 run.py --test-build --no-check-for-updates ./ci/test1.lpf - xvfb-run python3 run.py --test-build --no-check-for-updates ./ci/test2.lpf when: event: [ push, tag ] -# - name: Windows test -# image: ad5001/ubuntu-pyside6-xvfb-wine:win7-6.5.0-rev1 -# commands: -# - # For some reason, launching GUI apps with wine, even with xvfb-run, fails. -# - xvfb-run python run.py --test-build --no-check-for-updates -# - xvfb-run python run.py --test-build --no-check-for-updates ./ci/test1.lpf -# - xvfb-run python run.py --test-build --no-check-for-updates ./ci/test2.lpf -# when: -# event: [ push, tag ] -# - name: Linux packaging -# image: ad5001/ubuntu-pyside6-xvfb:jammy-6.5.0 -# commands: -# - bash scripts/package-linux.sh -# when: -# event: [ push, tag ] - - -- name: Windows building - image: ad5001/ubuntu-pyside6-xvfb-wine:win10-6.6.1 +- name: Windows build + image: ad5001/ubuntu-pyside6-xvfb-wine:win10-6.7.2 commands: - bash scripts/build-wine.sh - bash scripts/package-wine.sh diff --git a/tests/python/test_helper.py b/tests/python/test_helper.py index e57ec61..3e3975e 100644 --- a/tests/python/test_helper.py +++ b/tests/python/test_helper.py @@ -1,13 +1,16 @@ import pytest +from os import getcwd from os.path import join from tempfile import TemporaryDirectory from LogarithmPlotter.util import config +pwd = getcwd() + @pytest.fixture() -def resource(): +def temporary(): directory = TemporaryDirectory() config.CONFIG_PATH = join(directory.name, "config.json") - tmpfile = join(directory.name, 'graph.png') + tmpfile = join(directory.name, "graph.png") yield tmpfile - directory.cleanup() \ No newline at end of file + directory.cleanup() diff --git a/tests/python/test_pyjs.py b/tests/python/test_pyjs.py index 7765f30..2e632af 100644 --- a/tests/python/test_pyjs.py +++ b/tests/python/test_pyjs.py @@ -13,6 +13,7 @@ class TestPyJS: def test_set(self): obj.num1 = 2 obj.num2 = QJSValue(2) + obj.num3 = PyJSValue(QJSValue(2)) with pytest.raises(InvalidAttributeValueException): obj.num3 = object() @@ -20,6 +21,7 @@ class TestPyJS: obj.num = QJSValue(2) assert obj.num == 2 assert obj.num == QJSValue(2) + assert obj.num == PyJSValue(QJSValue(2)) assert obj.num != object() def test_function(self):