From 9d40645fd9c9c6eb99d87a3cf53e9fc1a633bb69 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 19 Jul 2019 09:26:42 +0200 Subject: [PATCH] [EDF19821] : 2 last vicious cases --- src/MEDCoupling_Swig/MEDCouplingExamplesTest.py | 12 ++++++++++++ src/PyWrapping/TestPyWrapGathered_medcoupling.py | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py b/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py index 26499420c..a13a0be18 100644 --- a/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py @@ -27,8 +27,20 @@ else: import unittest from math import pi, sqrt +def WriteInTmpDir(func): + def decoratedFunc(*args,**kwargs): + import tempfile,os + ret = None + with tempfile.TemporaryDirectory() as tmpdirname: + os.chdir(tmpdirname) + ret = func(*args,**kwargs) + pass + return ret + return decoratedFunc + class MEDCouplingBasicsTest(unittest.TestCase): + @WriteInTmpDir def testExample_MEDCouplingFieldDouble_WriteVTK(self): #! [PySnippet_MEDCouplingFieldDouble_WriteVTK_1] # mesh diff --git a/src/PyWrapping/TestPyWrapGathered_medcoupling.py b/src/PyWrapping/TestPyWrapGathered_medcoupling.py index 551df4689..825601e33 100644 --- a/src/PyWrapping/TestPyWrapGathered_medcoupling.py +++ b/src/PyWrapping/TestPyWrapGathered_medcoupling.py @@ -20,8 +20,20 @@ # Author : Anthony Geay (EDF R&D) from medcoupling import * + import unittest +def WriteInTmpDir(func): + def decoratedFunc(*args,**kwargs): + import tempfile,os + ret = None + with tempfile.TemporaryDirectory() as tmpdirname: + os.chdir(tmpdirname) + ret = func(*args,**kwargs) + pass + return ret + return decoratedFunc + class FileCreator(object): def __init__(self,tester,fname): self._tester=tester @@ -59,6 +71,7 @@ class medcouplingTest(unittest.TestCase): pass @unittest.skipUnless(HasMEDFileExt(),"Requires link to MED file") + @WriteInTmpDir def test1(self): import sys fname="mctest1.med" -- 2.39.2