Quellcode durchsuchen

add more testing for config.py

oz123 vor 11 Jahren
Ursprung
Commit
7467f21800
2 geänderte Dateien mit 10 neuen und 4 gelöschten Zeilen
  1. 9 3
      pwman/tests/db_tests.py
  2. 1 1
      pwman/util/config.py

+ 9 - 3
pwman/tests/db_tests.py

@@ -28,8 +28,7 @@ _saveconfig = False
 
 default_config['Database'] = {'type': 'SQLite',
                               'filename':
-                              os.path.join(os.path.dirname(__file__),
-                                           "test.pwman.db")
+                              os.path.join(os.path.dirname(__file__), "test.pwman.db")
                               }
 
 
@@ -187,7 +186,14 @@ class ConfigTest(unittest.TestCase):
 
     def test_config_write(self):
         config.save(os.path.join(os.path.dirname(__file__), 'testing_config'))
+
     def test_config_write_with_none(self):
-        config._file = os.path.join(os.path.dirname(__file__), 'testing_config')
+        config._file = os.path.join(os.path.dirname(__file__),
+                                    'testing_config')
         config.save()
 
+    def test_write_no_permission(self):
+        # this test will pass if you run as root ...
+        # assuming you are not doing something like that
+        self.assertRaises(config.ConfigException, config.save,
+                          '/root/test_config')

+ 1 - 1
pwman/util/config.py

@@ -29,7 +29,7 @@ class ConfigException(Exception):
         self.message = message
 
     def __str__(self):
-        return "%s: %s" % (self.__class__.__name__, self.message)
+        return "%s: %s" % (self.__class__.__name__, self.message)  # pragma: no cover
 
 
 class ConfigNoConfigException(ConfigException):