mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-06-28 03:06:14 +02:00
Updated tests.
This commit is contained in:
parent
c5b7df87f5
commit
ba3cde6112
2 changed files with 28 additions and 1 deletions
|
@ -132,7 +132,6 @@ class TestLSB(unittest.TestCase):
|
||||||
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||||
|
|
||||||
for message in messages_to_hide:
|
for message in messages_to_hide:
|
||||||
message = "Hello World"
|
|
||||||
outputBytes = io.BytesIO()
|
outputBytes = io.BytesIO()
|
||||||
with open("./tests/sample-files/20160505T130442.jpg", 'rb') as f:
|
with open("./tests/sample-files/20160505T130442.jpg", 'rb') as f:
|
||||||
bytes_image = lsb.hide(f, message)
|
bytes_image = lsb.hide(f, message)
|
||||||
|
@ -143,6 +142,19 @@ class TestLSB(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(message, clear_message)
|
self.assertEqual(message, clear_message)
|
||||||
|
|
||||||
|
def test_with_location_of_image_as_argument(self):
|
||||||
|
messages_to_hide = ["Hello World!"]
|
||||||
|
|
||||||
|
for message in messages_to_hide:
|
||||||
|
outputBytes = io.BytesIO()
|
||||||
|
bytes_image = lsb.hide("./tests/sample-files/20160505T130442.jpg", 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")
|
||||||
|
|
|
@ -25,6 +25,7 @@ __date__ = "$Date: 2016/04/13 $"
|
||||||
__revision__ = "$Date: 2017/05/04 $"
|
__revision__ = "$Date: 2017/05/04 $"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
@ -103,6 +104,20 @@ class TestLSBSet(unittest.TestCase):
|
||||||
secret = lsbset.hide("./tests/sample-files/Lenna-grayscale.png",
|
secret = lsbset.hide("./tests/sample-files/Lenna-grayscale.png",
|
||||||
message_to_hide, generators.eratosthenes())
|
message_to_hide, generators.eratosthenes())
|
||||||
|
|
||||||
|
def test_with_location_of_image_as_argument(self):
|
||||||
|
messages_to_hide = ["Hello World!"]
|
||||||
|
|
||||||
|
for message in messages_to_hide:
|
||||||
|
outputBytes = io.BytesIO()
|
||||||
|
bytes_image = lsbset.hide("./tests/sample-files/20160505T130442.jpg", message,
|
||||||
|
generators.identity())
|
||||||
|
bytes_image.save(outputBytes, "PNG")
|
||||||
|
outputBytes.seek(0)
|
||||||
|
|
||||||
|
clear_message = lsbset.reveal(outputBytes, generators.identity())
|
||||||
|
|
||||||
|
self.assertEqual(message, clear_message)
|
||||||
|
|
||||||
def test_auto_convert_rgb(self):
|
def test_auto_convert_rgb(self):
|
||||||
message_to_hide = "Hello World!"
|
message_to_hide = "Hello World!"
|
||||||
secret = lsbset.hide("./tests/sample-files/Lenna-grayscale.png",
|
secret = lsbset.hide("./tests/sample-files/Lenna-grayscale.png",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue