Skip to content

Commit

Permalink
Merge pull request #97 from koodaamo/fix-str-repr-tnef
Browse files Browse the repository at this point in the history
Fix str representation of TNEF
  • Loading branch information
petri authored Nov 28, 2020
2 parents 076fb99 + 7253cca commit d29d976
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ tnefparse 1.4.0 (unreleased)
- add Python 3.9 support (jugmac00)
- introduce using type annotations (jugmac00)
- remove deprecated parseFile & raw_mapi functions
- fix str representation for TNEF class (jugmac00)

tnefparse 1.3.1 (2020-09-30)
=============================
Expand Down
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 d29d976

Please sign in to comment.