mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
Update labeling unit tests control image and PAL_SUITE test suite generation
This commit is contained in:
parent
0a9b857177
commit
295854ad48
@ -210,7 +210,10 @@ class TestQgsPalLabeling(TestCase):
|
||||
return res
|
||||
|
||||
def saveContolImage(self, tmpimg=''):
|
||||
if 'PAL_CONTROL_IMAGE' not in os.environ:
|
||||
# don't save control images for RenderVsOtherOutput (Vs) tests, since
|
||||
# those control images belong to a different test result
|
||||
if ('PAL_CONTROL_IMAGE' not in os.environ
|
||||
or 'Vs' in self._TestGroup):
|
||||
return
|
||||
testgrpdir = 'expected_' + self._TestGroupPrefix
|
||||
testdir = os.path.join(self._TestDataDir, 'control_images',
|
||||
@ -228,6 +231,10 @@ class TestQgsPalLabeling(TestCase):
|
||||
else:
|
||||
self._Map.render()
|
||||
self._Canvas.saveAsImage(imgpath)
|
||||
# delete extraneous world file (always generated)
|
||||
wrld_file = imgbasepath + '.PNGw'
|
||||
if os.path.exists(wrld_file):
|
||||
os.remove(wrld_file)
|
||||
|
||||
def renderCheck(self, mismatch=0, imgpath='', grpprefix=''):
|
||||
"""Check rendered map canvas or existing image against control image
|
||||
@ -331,8 +338,12 @@ def runSuite(module, tests):
|
||||
"""This allows for a list of test names to be selectively run.
|
||||
Also, ensures unittest verbose output comes at end, after debug output"""
|
||||
loader = unittest.defaultTestLoader
|
||||
if 'PAL_SUITE' in os.environ and tests:
|
||||
suite = loader.loadTestsFromNames(tests, module)
|
||||
if 'PAL_SUITE' in os.environ:
|
||||
if tests:
|
||||
suite = loader.loadTestsFromNames(tests, module)
|
||||
else:
|
||||
raise Exception(
|
||||
"\n\n####__ 'PAL_SUITE' set, but no tests specified __####\n")
|
||||
else:
|
||||
suite = loader.loadTestsFromModule(module)
|
||||
verb = 2 if 'PAL_VERBOSE' in os.environ else 0
|
||||
|
@ -33,7 +33,10 @@ from utilities import (
|
||||
)
|
||||
|
||||
from test_qgspallabeling_base import TestQgsPalLabeling, runSuite
|
||||
from test_qgspallabeling_tests import TestPointBase
|
||||
from test_qgspallabeling_tests import (
|
||||
TestPointBase,
|
||||
suiteTests
|
||||
)
|
||||
|
||||
|
||||
class TestCanvasPoint(TestQgsPalLabeling, TestPointBase):
|
||||
@ -61,13 +64,9 @@ class TestCanvasPoint(TestQgsPalLabeling, TestPointBase):
|
||||
|
||||
if __name__ == '__main__':
|
||||
# NOTE: unless PAL_SUITE env var is set all test class methods will be run
|
||||
# ex: 'TestGroup(Point|Line|Curved|Polygon|Feature).test_method'
|
||||
suite = [
|
||||
'TestCanvasPoint.test_default_label',
|
||||
'TestCanvasPoint.test_text_size_map_unit',
|
||||
'TestCanvasPoint.test_text_color',
|
||||
'TestCanvasPoint.test_partials_labels_enabled',
|
||||
'TestCanvasPoint.test_partials_labels_disabled',
|
||||
]
|
||||
# SEE: test_qgspallabeling_tests.suiteTests() to define suite
|
||||
suite = (
|
||||
['TestCanvasPoint.' + t for t in suiteTests()['sp_suite']]
|
||||
)
|
||||
res = runSuite(sys.modules[__name__], suite)
|
||||
sys.exit(not res.wasSuccessful())
|
||||
|
@ -34,7 +34,10 @@ from utilities import (
|
||||
)
|
||||
|
||||
from test_qgspallabeling_base import TestQgsPalLabeling, runSuite
|
||||
from test_qgspallabeling_tests import TestPointBase
|
||||
from test_qgspallabeling_tests import (
|
||||
TestPointBase,
|
||||
suiteTests
|
||||
)
|
||||
|
||||
|
||||
# noinspection PyShadowingNames
|
||||
@ -152,19 +155,10 @@ class TestComposerVsCanvasPoint(TestComposerPoint):
|
||||
|
||||
if __name__ == '__main__':
|
||||
# NOTE: unless PAL_SUITE env var is set all test class methods will be run
|
||||
# ex: 'TestGroup(Point|Line|Curved|Polygon|Feature).test_method'
|
||||
suite = [
|
||||
'TestComposerPoint.test_default_label',
|
||||
'TestComposerPoint.test_text_size_map_unit',
|
||||
'TestComposerPoint.test_text_color',
|
||||
'TestComposerPoint.test_partials_labels_enabled',
|
||||
'TestComposerPoint.test_partials_labels_disabled',
|
||||
|
||||
'TestComposerVsCanvasPoint.test_default_label',
|
||||
'TestComposerVsCanvasPoint.test_text_size_map_unit',
|
||||
'TestComposerVsCanvasPoint.test_text_color',
|
||||
'TestComposerVsCanvasPoint.test_partials_labels_enabled',
|
||||
'TestComposerVsCanvasPoint.test_partials_labels_disabled',
|
||||
]
|
||||
# SEE: test_qgspallabeling_tests.suiteTests() to define suite
|
||||
suite = (
|
||||
['TestComposerPoint.' + t for t in suiteTests()['sp_suite']] +
|
||||
['TestComposerVsCanvasPoint.' + t for t in suiteTests()['sp_vs_suite']]
|
||||
)
|
||||
res = runSuite(sys.modules[__name__], suite)
|
||||
sys.exit(not res.wasSuccessful())
|
||||
|
@ -8,6 +8,8 @@ Set the following env variables when manually running tests:
|
||||
PAL_CONTROL_IMAGE to trigger building of new control images
|
||||
PAL_REPORT to open any failed image check reports in web browser
|
||||
|
||||
PAL_SERVER_TEMP to open the web server temp directory, instead of deleting
|
||||
|
||||
.. note:: This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
@ -44,7 +46,10 @@ from qgis_local_server import (
|
||||
)
|
||||
|
||||
from test_qgspallabeling_base import TestQgsPalLabeling, runSuite
|
||||
from test_qgspallabeling_tests import TestPointBase
|
||||
from test_qgspallabeling_tests import (
|
||||
TestPointBase,
|
||||
suiteTests
|
||||
)
|
||||
|
||||
MAPSERV = getLocalServer()
|
||||
|
||||
@ -83,9 +88,8 @@ class TestServerBase(TestQgsPalLabeling):
|
||||
TestQgsPalLabeling.tearDownClass()
|
||||
# layers removed, save empty project file
|
||||
cls._TestProj.write()
|
||||
if "PAL_REPORT" in os.environ:
|
||||
if "PAL_SERVER_TEMP" in os.environ:
|
||||
MAPSERV.stop_processes()
|
||||
# MAPSERV.fcgi_server_process().stop()
|
||||
MAPSERV.open_temp_dir()
|
||||
else:
|
||||
MAPSERV.shutdown()
|
||||
@ -173,21 +177,10 @@ class TestServerVsCanvasPoint(TestServerPoint):
|
||||
|
||||
if __name__ == '__main__':
|
||||
# NOTE: unless PAL_SUITE env var is set all test class methods will be run
|
||||
# ex: 'TestGroup(Point|Line|Curved|Polygon|Feature).test_method'
|
||||
suite = [
|
||||
'TestServerPoint.test_default_label',
|
||||
'TestServerPoint.test_text_size_map_unit',
|
||||
'TestServerPoint.test_text_color',
|
||||
'TestServerPoint.test_partials_labels_enabled',
|
||||
'TestServerPoint.test_partials_labels_disabled',
|
||||
|
||||
'TestServerVsCanvasPoint.test_default_label',
|
||||
'TestServerVsCanvasPoint.test_text_size_map_unit',
|
||||
'TestServerVsCanvasPoint.test_text_color',
|
||||
'TestServerVsCanvasPoint.test_partials_labels_enabled',
|
||||
'TestServerVsCanvasPoint.test_partials_labels_disabled',
|
||||
]
|
||||
# SEE: test_qgspallabeling_tests.suiteTests() to define suite
|
||||
suite = (
|
||||
['TestServerPoint.' + t for t in suiteTests()['sp_suite']] +
|
||||
['TestServerVsCanvasPoint.' + t for t in suiteTests()['sp_vs_suite']]
|
||||
)
|
||||
res = runSuite(sys.modules[__name__], suite)
|
||||
# if SPAWN:
|
||||
# os.remove(TESTPROJDIR) # remove temp directory (why does this error?)
|
||||
sys.exit(not res.wasSuccessful())
|
||||
|
@ -142,5 +142,24 @@ class TestPointBase(object):
|
||||
self.checkTest()
|
||||
|
||||
|
||||
# noinspection PyPep8Naming
|
||||
def suiteTests():
|
||||
"""
|
||||
Use to define which tests are run when PAL_SUITE is set.
|
||||
Use sp_vs_suite comparison of server and composer outputs to canvas
|
||||
"""
|
||||
return {
|
||||
'sp_suite': [
|
||||
# 'test_background_svg',
|
||||
'test_background_svg_w_offset',
|
||||
],
|
||||
'sp_vs_suite': [
|
||||
# 'test_background_svg',
|
||||
'test_background_svg_w_offset',
|
||||
# 'test_background_rect_w_offset',
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user