From 7018506e1f4661c3250d33e377fc622daab6c689 Mon Sep 17 00:00:00 2001
From: mham <mham@dtu.dk>
Date: Mon, 30 Nov 2020 10:31:29 +0100
Subject: [PATCH] adding cleanup method

---
 ellipsyswrapper/testsuite.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/ellipsyswrapper/testsuite.py b/ellipsyswrapper/testsuite.py
index 2e30f78..d5e50eb 100644
--- a/ellipsyswrapper/testsuite.py
+++ b/ellipsyswrapper/testsuite.py
@@ -300,7 +300,7 @@ class EllipSysTestCase(object):
                                            self.casedict['directory'])):
             raise unittest.SkipTest('Testcase directory not found')
 
-        case = CaseRunner(self.casedict)
+        self.case = case = CaseRunner(self.casedict)
         if 'casename' not in self.casedict.keys():
             case.casename = self.__class__.__name__.split('.')[-1]
         case.run_case()
@@ -346,3 +346,17 @@ class EllipSysTestCase(object):
                         np.testing.assert_allclose(expected, result,
                                                    rtol=10**(-case.tol),
                                                    atol=10**(-case.tol))
+
+    def tearDown(self):
+        """Clears the test folder before test machine loads to cache.
+        """
+
+        # get directory
+        testroot = '/'.join(self.case.directory.split('/')[:-1])
+        test_dir = os.path.join(testroot, self.case.casename)
+
+        if os.path.exists(test_dir):
+            print('removing test data')
+            os.system('ls -a *')
+            shutil.rmtree(test_dir)
+            os.system('ls -a *')
-- 
GitLab