| 1871 | # Test complicated multipart/* messages |
| 1872 | class TestMultipart(TestEmailBase): |
| 1873 | def setUp(self): |
| 1874 | with openfile('python.gif', 'rb') as fp: |
| 1875 | data = fp.read() |
| 1876 | container = MIMEBase('multipart', 'mixed', boundary='BOUNDARY') |
| 1877 | image = MIMEImage(data, name='dingusfish.gif') |
| 1878 | image.add_header('content-disposition', 'attachment', |
| 1879 | filename='dingusfish.gif') |
| 1880 | intro = MIMEText('''\ |
| 1881 | Hi there, |
| 1882 | |
| 1883 | This is the dingus fish. |
| 1884 | ''') |
| 1885 | container.attach(intro) |
| 1886 | container.attach(image) |
| 1887 | container['From'] = 'Barry <barry@digicool.com>' |
| 1888 | container['To'] = 'Dingus Lovers <cravindogs@cravindogs.com>' |
| 1889 | container['Subject'] = 'Here is your dingus fish' |
| 1890 | |
| 1891 | now = 987809702.54848599 |
| 1892 | timetuple = time.localtime(now) |
| 1893 | if timetuple[-1] == 0: |
| 1894 | tzsecs = time.timezone |
| 1895 | else: |
| 1896 | tzsecs = time.altzone |
| 1897 | if tzsecs > 0: |
| 1898 | sign = '-' |
| 1899 | else: |
| 1900 | sign = '+' |
| 1901 | tzoffset = ' %s%04d' % (sign, tzsecs / 36) |
| 1902 | container['Date'] = time.strftime( |
| 1903 | '%a, %d %b %Y %H:%M:%S', |
| 1904 | time.localtime(now)) + tzoffset |
| 1905 | self._msg = container |
| 1906 | self._im = image |
| 1907 | self._txt = intro |
| 1908 | |
| 1909 | def test_hierarchy(self): |
| 1910 | # convenience |