From 90b0ef1528ddbddd2cb8daa4a421d63a2b3d6027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Gmach?= Date: Sat, 28 Nov 2020 17:27:54 +0100 Subject: [PATCH] Fix str representation of TNEF new file: tests/test_tnef.py modified: tnefparse/tnef.py --- tests/test_tnef.py | 11 +++++++++++ tnefparse/tnef.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/test_tnef.py diff --git a/tests/test_tnef.py b/tests/test_tnef.py new file mode 100644 index 0000000..42ebec7 --- /dev/null +++ b/tests/test_tnef.py @@ -0,0 +1,11 @@ +import os +from tnefparse.tnef import TNEF + +THIS_DIR = os.path.dirname(os.path.abspath(__file__)) + + +def test_tnef_str_representation(): + tnef_data = open(os.path.join(THIS_DIR, "examples", "two-files.tnef"), mode="rb").read() + t = TNEF(tnef_data) + + assert str(t) == "" diff --git a/tnefparse/tnef.py b/tnefparse/tnef.py index bfc8f8b..082c4d3 100644 --- a/tnefparse/tnef.py +++ b/tnefparse/tnef.py @@ -337,7 +337,7 @@ def rtfbody(self): def __str__(self): atts = (", %i attachments" % len(self.attachments)) if self.attachments else '' - return f"<{self.__class__.__name__}:0x{self.key:2.2x}{atts}>" + return f"<{self.__class__.__name__}:0x{self.key:02x}{atts}>" def dump(self, force_strings=False): def get_data(a):