oz123 10 роки тому
батько
коміт
3b47cb6651
2 змінених файлів з 20 додано та 9 видалено
  1. 7 6
      pwman/tests/test_importer.py
  2. 13 3
      pwman/tests/test_init.py

+ 7 - 6
pwman/tests/test_importer.py

@@ -31,17 +31,18 @@ alice;wonderland.com;secert;scratch;foo,bar
 hatman;behindthemirror.com;pa33w0rd;scratch;foo,bar
 """
 
-with open('import_file.csv', 'w') as f:
-    f.write(import_example)
-
 
 class TestImporter(unittest.TestCase):
 
+    @classmethod
+    def setUpClass(cls):
+        with open('import_file.csv', 'w') as f:
+            f.write(import_example)
+
     @classmethod
     def tearDownClass(cls):
-        for item in ('dummy.cfg', 'import_file.csv',
-                     'test-importer.db', 'importdummy.db',
-                     'testfile.conf'):
+        for item in ('import_file.csv', 'test-importer.db',
+                     'testfile.conf', 'importdummy.db'):
             try:
                 os.unlink(item)
             except OSError:

+ 13 - 3
pwman/tests/test_init.py

@@ -38,12 +38,22 @@ cls_timeout = 5
 
 testdb = os.path.join(os.path.dirname(__file__), "test.pwman.db")
 
-with open('dummy.cfg', 'w') as d:
-    d.write(dummyfile)
-
 
 class TestInit(unittest.TestCase):
 
+    @classmethod
+    def setUpClass(cls):
+        with open('dummy.cfg', 'w') as d:
+            d.write(dummyfile)
+
+    @classmethod
+    def tearDownClass(cls):
+        for item in ('dummy.cfg'):
+            try:
+                os.unlink(item)
+            except OSError:
+                continue
+
     def test_set_xsel(self):
         Args = namedtuple('args', 'cfile, dbase, algo')
         args = Args(cfile='dummy.cfg', dbase='dummy.db', algo='AES')