self.get_boundary(), "--" if final else "")
def get_charset(self):
- return self.params.get("charset", 'ascii').lower()
+ default = 'ascii' if self.main == 'text' else None
+ c = self.params.get("charset", default)
+ if c:
+ c = c.lower()
+ return c
def set_charset(self, value):
self.params["charset"] = value.lower()
--- /dev/null
+from nose.tools import eq_
+
+from flanker.mime.message.headers.wrappers import ContentType
+
+def charset_test():
+ c = ContentType('text', 'plain')
+ eq_('ascii', c.get_charset())
+
+ c = ContentType('application', 'pdf')
+ eq_(None, c.get_charset())