From c4dd73470e2f3b7659b8993776b06bcb723eb438 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 14 Aug 2024 14:43:46 +0200 Subject: [PATCH] Fix tests --- .github/workflows/ci.yml | 1 + tests/test_core.py | 6 ++++-- tests/test_tools.py | 29 ++++++++++++++++------------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index efcc55d..41eca42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,7 @@ jobs: # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest + working-directory: tests run: | xvfb-run pytest -v diff --git a/tests/test_core.py b/tests/test_core.py index 5bc3d93..c991847 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -65,7 +65,8 @@ def test_replacement_feature(self): project.writeEntry(PLUGIN_SCOPE, PluginProjectProperty.Abstract, f"concat('Abstract ', \"folder\")") project.writeEntry(PLUGIN_SCOPE, PluginProjectProperty.Title, f"concat('Title ', \"folder\")") - vector = QgsVectorLayer(str(Path(f"fixtures/folder_1/lines_1.geojson")), f"Layer folder_1") + vector = QgsVectorLayer( + str(Path(__file__).parent.joinpath(f"fixtures/folder_1/lines_1.geojson")), f"Layer folder_1") self.assertTrue(vector.isValid()) project.addMapLayer(vector) @@ -142,7 +143,8 @@ def test_replacement_variables(self): project.writeEntry(PLUGIN_SCOPE, PluginProjectProperty.Abstract, f"concat('Abstract ', @x)") project.writeEntry(PLUGIN_SCOPE, PluginProjectProperty.Title, f"concat('Title ', @x)") - vector = QgsVectorLayer(str(Path(f"fixtures/folder_1/lines_1.geojson")), f"Layer folder_1") + vector = QgsVectorLayer( + str(Path(__file__).parent.joinpath(f"fixtures/folder_1/lines_1.geojson")), f"Layer folder_1") self.assertTrue(vector.isValid()) project.addMapLayer(vector) diff --git a/tests/test_tools.py b/tests/test_tools.py index c4e10d6..55076c0 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -30,9 +30,9 @@ def test_sidecar_files(self): expected = [side_1, side_2] expected.sort() self.assertListEqual(expected, side_car_files(test)) - - # def test_string_substitution(self): - # """ Test string substitution. """ + # + # def test_string_substitution_template(self): + # """ Test string substitution template. """ # self.assertEqual( # "Hello 1", # string_substitution( @@ -43,13 +43,16 @@ def test_sidecar_files(self): # is_template=True, # ) # ) - # self.assertEqual( - # "Hello 1", - # string_substitution( - # input_string="concat('Hello ', @here)", - # variables={ - # 'here': 1 - # }, - # is_template=False, - # ) - # ) + # + # def test_string_substitution_expression(self): + # """ Test string substitution expression. """ + # self.assertEqual( + # "Hello 1", + # string_substitution( + # input_string="concat('Hello ', @here)", + # variables={ + # 'here': 1 + # }, + # is_template=False, + # ) + # )