Skip to content

Commit

Permalink
Fix str representation of TNEF
Browse files Browse the repository at this point in the history
new file:   tests/test_tnef.py
modified:   tnefparse/tnef.py
  • Loading branch information
jugmac00 committed Nov 28, 2020
1 parent 076fb99 commit a9172cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions tests/test_tnef.py
Original file line number Diff line number Diff line change
@@ -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) == "<TNEF:0x237, 2 attachments>"
2 changes: 1 addition & 1 deletion tnefparse/tnef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit a9172cb

Please sign in to comment.