Skip to content

Commit

Permalink
Python tests: Close open files
Browse files Browse the repository at this point in the history
Debug builds/modes of Python will complain loudly about unclosed files,
making tests fail.
  • Loading branch information
encukou authored and ffesti committed Sep 25, 2023
1 parent a25d881 commit 5802192
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/rpmpython.at
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,16 @@ try:
myprint(h['arch'])
except rpm.error as e:
myprint(e)
sink.close()
],
[public key not available
],
)

RPMPY_TEST([reading a signed package file 2],[

keydata = open('${RPMDATA}/keys/rpm.org-rsa-2048-test.pub', 'rb').read()
with open('${RPMDATA}/keys/rpm.org-rsa-2048-test.pub', 'rb') as keydata_file:
keydata = keydata_file.read()
pubkey = rpm.pubkey(keydata)
keyring = rpm.keyring()
keyring.addKey(pubkey)
Expand Down Expand Up @@ -488,7 +490,8 @@ ts.closeDB()
ts.openDB()
c2 = ts.dbCookie()
myprint(c1 == c2 != None)
open("dbcookie", "w+").write(c1)
with open("dbcookie", "w+") as dbcookie_file:
dbcookie_file.write(c1)
],
[True
],
Expand All @@ -507,9 +510,11 @@ runroot rpm -i \
RPMPY_CHECK([
ts.openDB()
c1 = ts.dbCookie()
c2 = open("dbcookie", "r").read()
with open("dbcookie", "r") as dbcookie_file:
c2 = dbcookie_file.read()
myprint(c1 != c2)
open("dbcookie", "w+").write(c1)
with open("dbcookie", "w+") as dbcookie_file:
dbcookie_file.write(c1)
],
[True
],
Expand All @@ -529,7 +534,8 @@ runroot rpm -i \
RPMPY_CHECK([
ts.openDB()
c1 = ts.dbCookie()
c2 = open("dbcookie", "r").read()
with open("dbcookie", "r") as dbcookie_file:
c2 = dbcookie_file.read()
myprint(c1 != c2)
],
[True
Expand Down

0 comments on commit 5802192

Please sign in to comment.