Skip to content

Commit 450fb13

Browse files
committedFeb 23, 2016
[processing] Move AlgorithmTests to QgisAlgorithmTests
1 parent db60a04 commit 450fb13

File tree

4 files changed

+62
-21
lines changed

4 files changed

+62
-21
lines changed
 

‎python/plugins/processing/tests/AlgorithmsTest.py renamed to ‎python/plugins/processing/tests/AlgorithmsTestBase.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"""
44
***************************************************************************
5-
test_algorithms.py
5+
AlgorithmsTest.py
66
---------------------
77
Date : January 2016
88
Copyright : (C) 2016 by Matthias Kuhn
@@ -46,11 +46,6 @@
4646
QgsMapLayerRegistry
4747
)
4848

49-
from qgis.testing import (
50-
start_app,
51-
unittest
52-
)
53-
5449
from utilities import (
5550
unitTestDataPath
5651
)
@@ -60,25 +55,13 @@ def processingTestDataPath():
6055
return os.path.join(os.path.dirname(__file__), 'testdata')
6156

6257

63-
class TestAlgorithms(unittest.TestCase):
64-
65-
@classmethod
66-
def setUpClass(cls):
67-
start_app()
68-
from processing.core.Processing import Processing
69-
Processing.initialize()
70-
cls.cleanup_paths = []
71-
72-
@classmethod
73-
def tearDownClass(cls):
74-
for path in cls.cleanup_paths:
75-
shutil.rmtree(path)
58+
class AlgorithmsTest():
7659

7760
def test_algorithms(self):
7861
"""
7962
This is the main test function. All others will be executed based on the definitions in testdata/algorithm_tests.yaml
8063
"""
81-
with open(os.path.join(processingTestDataPath(), 'algorithm_tests.yaml'), 'r') as stream:
64+
with open(os.path.join(processingTestDataPath(), self.test_definition_file()), 'r') as stream:
8265
algorithm_tests = yaml.load(stream)
8366

8467
for algtest in algorithm_tests['tests']:

‎python/plugins/processing/tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ PLUGIN_INSTALL(processing tests/data ${TEST_DATA_FILES})
77
IF(ENABLE_TESTS)
88
INCLUDE(UsePythonTest)
99
ADD_PYTHON_TEST(ProcessingParametersTest ParametersTest.py)
10-
ADD_PYTHON_TEST(ProcessingAlgorithmsTest AlgorithmsTest.py)
10+
ADD_PYTHON_TEST(ProcessingQgisAlgorithmsTest QgisAlgorithmsTest.py)
1111
ENDIF(ENABLE_TESTS)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
QgisAlgorithmTests.py
6+
---------------------
7+
Date : January 2016
8+
Copyright : (C) 2016 by Matthias Kuhn
9+
Email : matthias@opengis.ch
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Matthias Kuhn'
21+
__date__ = 'January 2016'
22+
__copyright__ = '(C) 2016, Matthias Kuhn'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = ':%H$'
27+
28+
import AlgorithmsTestBase
29+
30+
import nose2
31+
import shutil
32+
33+
from qgis.testing import (
34+
start_app,
35+
unittest
36+
)
37+
38+
39+
class TestQgisAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
40+
41+
@classmethod
42+
def setUpClass(cls):
43+
start_app()
44+
from processing.core.Processing import Processing
45+
Processing.initialize()
46+
cls.cleanup_paths = []
47+
48+
@classmethod
49+
def tearDownClass(cls):
50+
for path in cls.cleanup_paths:
51+
shutil.rmtree(path)
52+
53+
def test_definition_file(self):
54+
return 'qgis_algorithm_tests.yaml'
55+
56+
57+
if __name__ == '__main__':
58+
nose2.main()

0 commit comments

Comments
 (0)
Please sign in to comment.