summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-05-19 22:38:17 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-05-19 22:38:17 (GMT)
commit5d09d85a5e606e5ac458abd37e72b73ce52541cb (patch)
tree9e9bd0581cc433fc7d8392a137b5a83dc46a9098 /tests
parent93b452d5258aa07d24ec233f2de930343be1d974 (diff)
Improved the use of the known format object.
Diffstat (limited to 'tests')
-rw-r--r--tests/format/known.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/format/known.py b/tests/format/known.py
new file mode 100644
index 0000000..056238f
--- /dev/null
+++ b/tests/format/known.py
@@ -0,0 +1,44 @@
+#!/usr/bin/python3-dbg
+# -*- coding: utf-8 -*-
+
+
+from chrysacase import ChrysalideTestCase
+from pychrysalide.analysis.contents import MemoryContent
+from pychrysalide.format import KnownFormat
+
+
+class TestKnownFormat(ChrysalideTestCase):
+ """TestCase for format.KnownFormat."""
+
+
+ def testKnownFormatConstructor(self):
+ """Build Load a simple content for a flat format."""
+
+ with self.assertRaisesRegex(RuntimeError, 'pychrysalide.format.KnownFormat is an abstract class'):
+ fmt = KnownFormat()
+
+ class MyKnownFormat(KnownFormat):
+ pass
+
+ with self.assertRaisesRegex(TypeError, 'function takes exactly 1 argument .0 given.'):
+ fmt = MyKnownFormat()
+
+ class MyKnownFormat2(KnownFormat):
+ pass
+
+ with self.assertRaisesRegex(TypeError, 'unable to convert the provided argument to binary content'):
+ fmt = MyKnownFormat2(123)
+
+ class MyKnownFormatReady(KnownFormat):
+ _key = 'rdy'
+ def __init2__(self, cnt):
+ super(MyKnownFormatReady, self).__init2__(cnt)
+
+ data = b'\x00\x00\x00\xef'
+
+ cnt = MemoryContent(data)
+ fmt = MyKnownFormatReady(cnt)
+
+ self.assertIsNotNone(fmt)
+
+ self.assertEqual(fmt.key, 'rdy')