From a7a0e6ac340113ace8489d7e1ae439cf3eb04477 Mon Sep 17 00:00:00 2001 From: "Anders H. Rebner" <anderhre@stud.ntnu.no> Date: Fri, 27 Mar 2020 09:23:08 +0100 Subject: [PATCH] =?UTF-8?q?Sjekker=20om=20filer=20eksisterer=20f=C3=B8r=20?= =?UTF-8?q?de=20slettes=20i=20testene?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_codebook_to_pdf.py | 11 +++++++---- test/test_database.py | 2 +- test/test_main_window.py | 2 +- test/test_serialize_export_import.py | 6 ++++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/test/test_codebook_to_pdf.py b/test/test_codebook_to_pdf.py index 3dafcf7..b3d5ef0 100644 --- a/test/test_codebook_to_pdf.py +++ b/test/test_codebook_to_pdf.py @@ -50,7 +50,10 @@ class ExportTest(unittest.TestCase): self.assertTrue(os.path.exists(file_path_small)) # Delete generated files - os.remove(file_path_full) - os.remove(file_path_small) - database.conn.close() - os.remove(TESTDBPATH) + if os.path.exists(file_path_full): + os.remove(file_path_full) + if os.path.exists(file_path_small): + os.remove(file_path_small) + if os.path.exists(TESTDBPATH): + database.conn.close() + os.remove(TESTDBPATH) diff --git a/test/test_database.py b/test/test_database.py index 84a5b2d..b34691a 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -295,8 +295,8 @@ class DatabaseTest(unittest.TestCase): def delete_db(self): """Delete generated database-file.""" - self.database.conn.close() if os.path.exists(TESTDBPATH): + self.database.conn.close() os.remove(TESTDBPATH) diff --git a/test/test_main_window.py b/test/test_main_window.py index 8026c26..311f873 100644 --- a/test/test_main_window.py +++ b/test/test_main_window.py @@ -34,8 +34,8 @@ class TestMainWindow(unittest.TestCase): def delete_db(self): """Delete generated 'testDatabase'-file.""" - self.test_mw.database.conn.close() if os.path.exists(TESTDBPATH): + self.test_mw.database.conn.close() os.remove(TESTDBPATH) diff --git a/test/test_serialize_export_import.py b/test/test_serialize_export_import.py index 267c34f..9ea2f99 100644 --- a/test/test_serialize_export_import.py +++ b/test/test_serialize_export_import.py @@ -135,5 +135,7 @@ class SerializeTest(unittest.TestCase): self.assertEqual(MODULES[1]["meta"], soi.modules[1]["meta"]) # Delete exported SOI-files - os.remove(self.file_path) - os.remove(invalid_soi_file_path) + if os.path.exists(self.file_path): + os.remove(self.file_path) + if os.path.exists(invalid_soi_file_path): + os.remove(invalid_soi_file_path) -- GitLab