From a060757f76b3e263f848faf9924c20d811bc93d0 Mon Sep 17 00:00:00 2001 From: AdrienCos Date: Thu, 6 Jun 2019 22:36:06 -0400 Subject: [PATCH] Added steganalysis.statistics unit test --- tests/expected-results/statistics | 1 + tests/test_steganalysis.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/expected-results/statistics diff --git a/tests/expected-results/statistics b/tests/expected-results/statistics new file mode 100644 index 0000000..028dc2e --- /dev/null +++ b/tests/expected-results/statistics @@ -0,0 +1 @@ +([58, 56, 54, 57, 60, 59, 62, 61, 63, 65, 64, 66, 67, 254, 68, 69, 255, 70, 253, 71, 72, 74, 252, 73, 251, 250, 75, 249, 76, 77], [(224, 4327), (221, 4138), (223, 4057), (222, 3987), (225, 3713), (220, 3554), (209, 3516), (207, 3476), (208, 3424), (219, 3360)]) diff --git a/tests/test_steganalysis.py b/tests/test_steganalysis.py index 61dac1c..8103f5d 100644 --- a/tests/test_steganalysis.py +++ b/tests/test_steganalysis.py @@ -32,7 +32,7 @@ import unittest from unittest.mock import patch from stegano import lsb -from stegano.steganalysis import parity +from stegano.steganalysis import parity, statistics from PIL import Image, ImageChops @@ -59,6 +59,16 @@ class TestSteganalysis(unittest.TestCase): diff = ImageChops.difference(target, analysis).getbbox() self.assertTrue(diff is None) + def test_statistics(self): + """ Test stegano.steganalysis.statistics + """ + image = Image.open("./tests/sample-files/Lenna.png") + stats = str(statistics.steganalyse(image)) + '\n' + file = open("./tests/expected-results/statistics") + target = file.read() + file.close() + self.assertEqual(stats, target) + if __name__ == '__main__': unittest.main()