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,12 +86,11 @@ class TestEXIFHeader(unittest.TestCase):
|
||||||
def test_with_bytes(self):
|
def test_with_bytes(self):
|
||||||
outputBytes = io.BytesIO()
|
outputBytes = io.BytesIO()
|
||||||
message = b"Secret"
|
message = b"Secret"
|
||||||
exifHeader.hide(open("./tests/sample-files/20160505T130442.jpg", 'rb'),
|
with open("./tests/sample-files/20160505T130442.jpg", 'rb') as f:
|
||||||
outputBytes,
|
exifHeader.hide(f, outputBytes, secret_message=message)
|
||||||
secret_message=message)
|
|
||||||
|
|
||||||
clear_message = exifHeader.reveal(outputBytes)
|
clear_message = exifHeader.reveal(outputBytes)
|
||||||
self.assertEqual(message, clear_message)
|
self.assertEqual(message, clear_message)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -134,13 +134,14 @@ class TestLSB(unittest.TestCase):
|
||||||
for message in messages_to_hide:
|
for message in messages_to_hide:
|
||||||
message = "Hello World"
|
message = "Hello World"
|
||||||
outputBytes = io.BytesIO()
|
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.save(outputBytes, "PNG")
|
bytes_image = lsb.hide(f, message)
|
||||||
outputBytes.seek(0)
|
bytes_image.save(outputBytes, "PNG")
|
||||||
|
outputBytes.seek(0)
|
||||||
|
|
||||||
clear_message = lsb.reveal(outputBytes)
|
clear_message = lsb.reveal(outputBytes)
|
||||||
|
|
||||||
self.assertEqual(message, clear_message)
|
self.assertEqual(message, clear_message)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Reference in a new issue