Skip to content

Commit

Permalink
test: Update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
dalcinl committed Mar 12, 2015
1 parent 9f6c882 commit 559e6de
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/test_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,21 @@ def close(self):

class BaseTestMyFile(object):

def setUp(self):
def openfile(self):
fd, fname = tempfile.mkstemp(prefix='mpi4py')
os.close(fd)
amode = MPI.MODE_RDWR | MPI.MODE_CREATE | MPI.MODE_DELETE_ON_CLOSE
try:
f = MPI.File.Open(MPI.COMM_SELF,
fname, amode,
MPI.INFO_NULL)
self.file = MyFile(f)
self.file = MPI.File.Open(MPI.COMM_SELF, fname, amode, MPI.INFO_NULL)
return self.file
except Exception:
os.remove(fname)
raise

def setUp(self):
f = self.openfile()
self.file = MyFile(f)

def tearDown(self):
if self.file:
self.file.Close()
Expand All @@ -295,8 +297,7 @@ class TestMyFile(BaseTestMyFile, unittest.TestCase):
del TestMyFile
try:
dummy = BaseTestMyFile()
dummy.setUp()
dummy.tearDown()
dummy.openfile().Close()
del dummy
except NotImplementedError:
try: del TestMyFile
Expand Down

0 comments on commit 559e6de

Please sign in to comment.