Quellcode durchsuchen

Remove clean_all in favor of tearDownClass

oz123 vor 10 Jahren
Ursprung
Commit
e9a6b1ae7a
4 geänderte Dateien mit 19 neuen und 22 gelöschten Zeilen
  1. 0 4
      Makefile
  2. 3 7
      pwman/tests/test_base_ui.py
  3. 10 4
      pwman/tests/test_config.py
  4. 6 7
      pwman/tests/test_importer.py

+ 0 - 4
Makefile

@@ -17,11 +17,7 @@ clean_all:
 	clean_coverage_report
 
 clean: clean-build clean-pyc
-	#rm -fr htmlcov/
 	rm -f test.db
-	python -c "from pwman.tests.test_base_ui import TestBaseUI; TestBaseUI.clean_all()"
-	python -c "from pwman.tests.test_importer import TestImporter; TestImporter.clean_all()"
-	python -c "from pwman.tests.test_config import TestConfig; TestConfig.clean_all()"
 	rm -f pwman/tests/test.conf 
 
 clean_docs:

+ 3 - 7
pwman/tests/test_base_ui.py

@@ -48,8 +48,8 @@ class dummy_stdin(object):
 
 class TestBaseUI(unittest.TestCase):
 
-    @staticmethod
-    def clean_all():
+    @classmethod
+    def tearDownClass(cls):
         for item in (testdb, 'foo.csv', 'pwman-export.csv'):
             try:
                 os.unlink(item)
@@ -190,8 +190,4 @@ if __name__ == '__main__':
     ce = CryptoEngine.get()
     ce.callback = DummyCallback()
     ce.changepassword(reader=give_key)
-
-    try:
-        unittest.main(verbosity=2, failfast=True)
-    except SystemExit:
-        TestBaseUI.clean_all()
+    unittest.main(verbosity=2, failfast=True)

+ 10 - 4
pwman/tests/test_config.py

@@ -55,6 +55,15 @@ class TestConfig(unittest.TestCase):
             except OSError:
                 continue
 
+    @classmethod
+    def tearDownClass(cls):
+        for item in ('testfile.conf', 'wrong_conf.conf', 'dummy.cfg',
+                     'import_file.csv'):
+            try:
+                os.unlink(item)
+            except OSError:
+                continue
+
     def setUp(self):
         self.conf = Config(filename='testfile.conf', defaults=default_config)
 
@@ -90,7 +99,4 @@ algorithm = Blowfish
                           self.conf.set_value, *('Error', 'colors', 'no'))
 
 if __name__ == '__main__':
-    try:
-        unittest.main(verbosity=2)
-    except SystemExit:
-        TestConfig.clean_all()
+    unittest.main(verbosity=2)

+ 6 - 7
pwman/tests/test_importer.py

@@ -37,9 +37,11 @@ with open('import_file.csv', 'w') as f:
 
 class TestImporter(unittest.TestCase):
 
-    @staticmethod
-    def clean_all():
-        for item in ('import_file.csv', 'test-importer.db', 'importdummy.db'):
+    @classmethod
+    def tearDownClass(cls):
+        for item in ('dummy.cfg', 'import_file.csv',
+                     'test-importer.db', 'importdummy.db',
+                     'testfile.conf'):
             try:
                 os.unlink(item)
             except OSError:
@@ -99,7 +101,4 @@ if __name__ == '__main__':
     ce = CryptoEngine.get()
     ce.callback = DummyCallback()
     ce.changepassword(reader=give_key)
-    try:
-        unittest.main(verbosity=2, failfast=True)
-    except SystemExit:
-        TestImporter.clean_all()
+    unittest.main(verbosity=2, failfast=True)