| 1849 | # Test complicated multipart/* messages |
| 1850 | class TestMultipart(TestEmailBase): |
| 1851 | def setUp(self): |
| 1852 | with openfile('python.gif', 'rb') as fp: |
| 1853 | data = fp.read() |
| 1854 | container = MIMEBase('multipart', 'mixed', boundary='BOUNDARY') |
| 1855 | image = MIMEImage(data, name='dingusfish.gif') |
| 1856 | image.add_header('content-disposition', 'attachment', |
| 1857 | filename='dingusfish.gif') |
| 1858 | intro = MIMEText('''\ |
| 1859 | Hi there, |
| 1860 | |
| 1861 | This is the dingus fish. |
| 1862 | ''') |
| 1863 | container.attach(intro) |
| 1864 | container.attach(image) |
| 1865 | container['From'] = 'Barry <barry@digicool.com>' |
| 1866 | container['To'] = 'Dingus Lovers <cravindogs@cravindogs.com>' |
| 1867 | container['Subject'] = 'Here is your dingus fish' |
| 1868 | |
| 1869 | now = 987809702.54848599 |
| 1870 | timetuple = time.localtime(now) |
| 1871 | if timetuple[-1] == 0: |
| 1872 | tzsecs = time.timezone |
| 1873 | else: |
| 1874 | tzsecs = time.altzone |
| 1875 | if tzsecs > 0: |
| 1876 | sign = '-' |
| 1877 | else: |
| 1878 | sign = '+' |
| 1879 | tzoffset = ' %s%04d' % (sign, tzsecs / 36) |
| 1880 | container['Date'] = time.strftime( |
| 1881 | '%a, %d %b %Y %H:%M:%S', |
| 1882 | time.localtime(now)) + tzoffset |
| 1883 | self._msg = container |
| 1884 | self._im = image |
| 1885 | self._txt = intro |
| 1886 | |
| 1887 | def test_hierarchy(self): |
| 1888 | # convenience |