[GRASS-SVN] r65597 - grass/trunk/lib/python/pygrass/modules/interface/testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jul 16 02:40:30 PDT 2015
Author: zarch
Date: 2015-07-16 02:40:30 -0700 (Thu, 16 Jul 2015)
New Revision: 65597
Added:
grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_flag.py
Log:
pygrass: add test for Flag object
Added: grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_flag.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_flag.py (rev 0)
+++ grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_flag.py 2015-07-16 09:40:30 UTC (rev 65597)
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Tue Jun 24 09:43:53 2014
+
+ at author: pietro
+"""
+from __future__ import unicode_literals
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+
+from grass.pygrass.modules.interface.flag import Flag
+
+
+class TestFlag(TestCase):
+ def test_get_bash(self):
+ """Test get_bash method"""
+ flag = Flag(diz=dict(name='a'))
+ self.assertFalse(flag.value)
+ self.assertEqual('', flag.get_bash())
+ flag.special = True
+ self.assertEqual('', flag.get_bash())
+ flag.value = True
+ self.assertEqual('--a', flag.get_bash())
+ flag.special = False
+ self.assertEqual('-a', flag.get_bash())
+
+ def test_get_python(self):
+ """Test get_python method"""
+ flag = Flag(diz=dict(name='a'))
+ self.assertFalse(flag.value)
+ self.assertEqual('', flag.get_python())
+ flag.special = True
+ self.assertEqual('', flag.get_python())
+ flag.value = True
+ self.assertEqual('a=True', flag.get_python())
+ flag.special = False
+ self.assertEqual('a', flag.get_python())
+
+ def test_bool(self):
+ """Test magic __bool__ method"""
+ flag = Flag(diz=dict(name='a'))
+ flag.value = True
+ self.assertTrue(True if flag else False)
+ flag.value = False
+ self.assertFalse(True if flag else False)
+
+
+if __name__ == '__main__':
+ test()
Property changes on: grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_flag.py
___________________________________________________________________
Added: svn:mime-type
+ text/x-python
Added: svn:eol-style
+ native
More information about the grass-commit
mailing list