Skip to content

Commit

Permalink
Add a test for saveNamedStyle to file path
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Oct 25, 2018
1 parent 08f2a02 commit 6afb8de
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/src/python/test_qgsmaplayer.py
Expand Up @@ -12,6 +12,7 @@
# This will get replaced with a git SHA1 when you do a git archive # This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$' __revision__ = '$Format:%H$'


import os
import qgis # NOQA import qgis # NOQA
import tempfile import tempfile


Expand All @@ -20,6 +21,7 @@
QgsProject) QgsProject)
from qgis.testing import start_app, unittest from qgis.testing import start_app, unittest
from qgis.PyQt.QtXml import QDomDocument from qgis.PyQt.QtXml import QDomDocument
from qgis.PyQt.QtCore import QTemporaryDir


start_app() start_app()


Expand Down Expand Up @@ -105,6 +107,15 @@ def testReadWriteMetadata(self):
self.assertTrue(status) self.assertTrue(status)
self.assertTrue(layer2.metadata().abstract(), 'My abstract') self.assertTrue(layer2.metadata().abstract(), 'My abstract')


def testSaveNamedStyle(self):
layer = QgsVectorLayer("Point?field=fldtxt:string", "layer", "memory")
dir = QTemporaryDir()
dir_path = dir.path()
style_path = os.path.join(dir_path, 'my.qml')
_, result = layer.saveNamedStyle(style_path)
self.assertTrue(result)
self.assertTrue(os.path.exists(style_path))



if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

0 comments on commit 6afb8de

Please sign in to comment.