tests: close files

This commit is contained in:
Daniel Martí 2015-10-08 13:20:35 +02:00
parent f7e9022217
commit 00bd75aa8c
3 changed files with 10 additions and 5 deletions

View File

@ -63,11 +63,13 @@ class BuildTest(unittest.TestCase):
'source-files/Zillode/syncthing-silk/build.gradle',
'source-files/open-keychain/open-keychain/build.gradle',
'source-files/osmandapp/osmand/build.gradle'):
filedata = open(os.path.join(testsdir, f)).read()
with open(os.path.join(testsdir, f), 'r') as f:
filedata = f.read()
self.assertIsNotNone(pattern.search(filedata))
tp = os.path.join(testsdir,
'source-files/open-keychain/open-keychain/OpenKeychain/build.gradle')
filedata = open(tp).read()
with open(tp, 'r') as f:
filedata = f.read()
self.assertIsNone(pattern.search(filedata))
if __name__ == "__main__":

View File

@ -140,10 +140,12 @@ class CommonTest(unittest.TestCase):
fdroidserver.common.prepare_source(FakeVcs(), app, build, testdir, testdir, testdir)
filedata = open(os.path.join(testdir, 'build.gradle')).read()
with open(os.path.join(testdir, 'build.gradle'), 'r') as f:
filedata = f.read()
self.assertIsNotNone(re.search("\s+compileSdkVersion %s\s+" % testint, filedata))
filedata = open(os.path.join(testdir, 'AndroidManifest.xml')).read()
with open(os.path.join(testdir, 'AndroidManifest.xml')) as f:
filedata = f.read()
self.assertIsNone(re.search('android:debuggable', filedata))
self.assertIsNotNone(re.search('android:versionName="%s"' % build['version'], filedata))
self.assertIsNotNone(re.search('android:versionCode="%s"' % build['vercode'], filedata))

View File

@ -39,7 +39,8 @@ class MetadataTest(unittest.TestCase):
apps = fdroidserver.metadata.read_metadata(xref=True)
for appid in ('org.smssecure.smssecure', 'org.adaway', 'net.osmand.plus', 'org.videolan.vlc'):
frompickle = pickle.load(open(os.path.join('metadata', appid + '.pickle')))
with open(os.path.join('metadata', appid + '.pickle'), 'r') as f:
frompickle = pickle.load(f)
self.assertTrue(appid in apps.keys())
self.assertEquals(apps[appid], frompickle)