From d952cd3e7b800741af3c1a8f7fc03121e0bee1be Mon Sep 17 00:00:00 2001 From: Gregory Ashton Date: Tue, 30 Jan 2018 21:57:45 -0800 Subject: [PATCH] Add warning message (but pass) when errors are encountered in removing test directories Closes #12 --- tests.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests.py b/tests.py index 4b853e4..bf92c9f 100644 --- a/tests.py +++ b/tests.py @@ -4,6 +4,7 @@ import os import shutil import pyfstat import lalpulsar +import logging class Test(unittest.TestCase): @@ -12,7 +13,11 @@ class Test(unittest.TestCase): @classmethod def setUpClass(self): if os.path.isdir(self.outdir): - shutil.rmtree(self.outdir) + try: + shutil.rmtree(self.outdir) + except OSError: + logging.warning( + "{} not removed prior to tests".format(self.outdir)) h0 = 1 sqrtSX = 1 F0 = 30 @@ -38,7 +43,11 @@ class Test(unittest.TestCase): @classmethod def tearDownClass(self): if os.path.isdir(self.outdir): - shutil.rmtree(self.outdir) + try: + shutil.rmtree(self.outdir) + except OSError: + logging.warning( + "{} not removed prior to tests".format(self.outdir)) class Writer(Test): -- GitLab