summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
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')