mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-12 17:18:30 +02:00
Merge pull request #21 from BoboTiG/fix-resource-warnings
Fix ResourceWarning: unclosed file, in tests
This commit is contained in:
commit
9f2f73973a
2 changed files with 10 additions and 10 deletions
|
@ -86,9 +86,8 @@ class TestEXIFHeader(unittest.TestCase):
|
|||
def test_with_bytes(self):
|
||||
outputBytes = io.BytesIO()
|
||||
message = b"Secret"
|
||||
exifHeader.hide(open("./tests/sample-files/20160505T130442.jpg", 'rb'),
|
||||
outputBytes,
|
||||
secret_message=message)
|
||||
with open("./tests/sample-files/20160505T130442.jpg", 'rb') as f:
|
||||
exifHeader.hide(f, outputBytes, secret_message=message)
|
||||
|
||||
clear_message = exifHeader.reveal(outputBytes)
|
||||
self.assertEqual(message, clear_message)
|
||||
|
|
|
@ -134,7 +134,8 @@ class TestLSB(unittest.TestCase):
|
|||
for message in messages_to_hide:
|
||||
message = "Hello World"
|
||||
outputBytes = io.BytesIO()
|
||||
bytes_image = lsb.hide(open("./tests/sample-files/20160505T130442.jpg", 'rb'), message)
|
||||
with open("./tests/sample-files/20160505T130442.jpg", 'rb') as f:
|
||||
bytes_image = lsb.hide(f, message)
|
||||
bytes_image.save(outputBytes, "PNG")
|
||||
outputBytes.seek(0)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue