testgit: use with statements to open files.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
This commit is contained in:
parent
74ab2d9fc7
commit
d66aa22c12
1 changed files with 4 additions and 6 deletions
|
|
@ -13,9 +13,8 @@ import unittest
|
|||
class TestGitTransactions(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tempdir = tempfile.TemporaryDirectory()
|
||||
fp = open(self.tempdir.name + "/schema", "w")
|
||||
fp.write("fmt:0:newfol schema file:\ntxn:git\n")
|
||||
fp.close()
|
||||
with open(self.tempdir.name + "/schema", "w") as fp:
|
||||
fp.write("fmt:0:newfol schema file:\ntxn:git\n")
|
||||
self.db = newfol.database.Database.load(self.tempdir.name)
|
||||
|
||||
def tearDown(self):
|
||||
|
|
@ -58,9 +57,8 @@ class TestGitTransactions(unittest.TestCase):
|
|||
data = None
|
||||
try:
|
||||
os.chdir(self.tempdir.name)
|
||||
fp = os.popen("git log --pretty=format:" + fmt + " -n1")
|
||||
data = fp.read()
|
||||
fp.close()
|
||||
with os.popen("git log --pretty=format:" + fmt + " -n1") as fp:
|
||||
data = fp.read()
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
return data
|
||||
|
|
|
|||
Loading…
Reference in a new issue