mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-12 17:18:30 +02:00
Test when the data image is coming via byte stream.
This commit is contained in:
parent
cf89273c57
commit
36476283a4
1 changed files with 15 additions and 0 deletions
|
@ -24,6 +24,7 @@ __version__ = "$Revision: 0.1 $"
|
||||||
__date__ = "$Date: 2016/04/12 $"
|
__date__ = "$Date: 2016/04/12 $"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
@ -77,6 +78,20 @@ class TestLSB(unittest.TestCase):
|
||||||
with self.assertRaises(Exception):
|
with self.assertRaises(Exception):
|
||||||
lsb.hide("./tests/sample-files/Lenna.png", message)
|
lsb.hide("./tests/sample-files/Lenna.png", message)
|
||||||
|
|
||||||
|
def test_with_bytes(self):
|
||||||
|
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||||
|
|
||||||
|
for message in messages_to_hide:
|
||||||
|
message = "Hello World"
|
||||||
|
outputBytes = io.BytesIO()
|
||||||
|
bytes_image = lsb.hide(open("./tests/sample-files/20160505T130442.jpg", 'rb'), message)
|
||||||
|
bytes_image.save(outputBytes, "PNG")
|
||||||
|
outputBytes.seek(0)
|
||||||
|
|
||||||
|
clear_message = lsb.reveal(outputBytes)
|
||||||
|
|
||||||
|
self.assertEqual(message, clear_message)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
try:
|
try:
|
||||||
os.unlink("./image.png")
|
os.unlink("./image.png")
|
||||||
|
|
Loading…
Add table
Reference in a new issue