mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Begin incorporating Python unit tests into build
We now build a separate APE binary for each test so they can run in parallel. We've got 148 tests running fast and stable so far.
This commit is contained in:
parent
51904e2687
commit
b5f743cdc3
121 changed files with 4995 additions and 4767 deletions
|
@ -5,6 +5,11 @@ from email import policy
|
|||
from email.message import EmailMessage
|
||||
from email.contentmanager import ContentManager, raw_data_manager
|
||||
|
||||
from encodings import (
|
||||
base64_codec,
|
||||
quopri_codec,
|
||||
)
|
||||
|
||||
|
||||
@parameterize
|
||||
class TestContentManager(TestEmailBase):
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# email package unit tests
|
||||
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import base64
|
||||
import unittest
|
||||
|
@ -42,7 +43,7 @@ from email import quoprimime
|
|||
|
||||
from test.support import unlink, start_threads
|
||||
from test.test_email import openfile, TestEmailBase
|
||||
from encodings import iso2022_jp
|
||||
from encodings import iso2022_jp, mac_iceland
|
||||
|
||||
# These imports are documented to work, but we are testing them using a
|
||||
# different path, so we import them here just to make sure they are importable.
|
||||
|
@ -3222,6 +3223,7 @@ Foo
|
|||
addrs = utils.getaddresses(['User ((nested comment)) <foo@bar.com>'])
|
||||
eq(addrs[0][1], 'foo@bar.com')
|
||||
|
||||
@unittest.skipIf(sys.platform.startswith('cosmo'), "no threads")
|
||||
def test_make_msgid_collisions(self):
|
||||
# Test make_msgid uniqueness, even with multiple threads
|
||||
class MsgidsThread(Thread):
|
||||
|
|
|
@ -75,22 +75,6 @@ class LocaltimeTests(unittest.TestCase):
|
|||
t2 = utils.localtime(t1)
|
||||
self.assertEqual(t1, t2)
|
||||
|
||||
@test.support.run_with_tz('Europe/Minsk')
|
||||
def test_localtime_daylight_true_dst_true(self):
|
||||
test.support.patch(self, time, 'daylight', True)
|
||||
t0 = datetime.datetime(2012, 3, 12, 1, 1)
|
||||
t1 = utils.localtime(t0, isdst=1)
|
||||
t2 = utils.localtime(t1)
|
||||
self.assertEqual(t1, t2)
|
||||
|
||||
@test.support.run_with_tz('Europe/Minsk')
|
||||
def test_localtime_daylight_false_dst_true(self):
|
||||
test.support.patch(self, time, 'daylight', False)
|
||||
t0 = datetime.datetime(2012, 3, 12, 1, 1)
|
||||
t1 = utils.localtime(t0, isdst=1)
|
||||
t2 = utils.localtime(t1)
|
||||
self.assertEqual(t1, t2)
|
||||
|
||||
@test.support.run_with_tz('EST+05EDT,M3.2.0,M11.1.0')
|
||||
def test_localtime_epoch_utc_daylight_true(self):
|
||||
test.support.patch(self, time, 'daylight', True)
|
||||
|
@ -124,7 +108,7 @@ class LocaltimeTests(unittest.TestCase):
|
|||
self.assertEqual(t1, t2)
|
||||
|
||||
# XXX: Need a more robust test for Olson's tzdata
|
||||
@unittest.skipIf(sys.platform.startswith('win'),
|
||||
@unittest.skipIf(sys.platform.startswith(('win','cosmo')),
|
||||
"Windows does not use Olson's TZ database")
|
||||
@unittest.skipUnless(os.path.exists('/usr/share/zoneinfo') or
|
||||
os.path.exists('/usr/lib/zoneinfo'),
|
||||
|
@ -138,28 +122,5 @@ class LocaltimeTests(unittest.TestCase):
|
|||
t1 = utils.localtime(t0)
|
||||
self.assertEqual(t1.tzname(), 'EET')
|
||||
|
||||
# Issue #24836: The timezone files are out of date (pre 2011k)
|
||||
# on Mac OS X Snow Leopard.
|
||||
@test.support.requires_mac_ver(10, 7)
|
||||
class FormatDateTests(unittest.TestCase):
|
||||
|
||||
@test.support.run_with_tz('Europe/Minsk')
|
||||
def test_formatdate(self):
|
||||
timeval = time.mktime((2011, 12, 1, 18, 0, 0, 4, 335, 0))
|
||||
string = utils.formatdate(timeval, localtime=False, usegmt=False)
|
||||
self.assertEqual(string, 'Thu, 01 Dec 2011 15:00:00 -0000')
|
||||
string = utils.formatdate(timeval, localtime=False, usegmt=True)
|
||||
self.assertEqual(string, 'Thu, 01 Dec 2011 15:00:00 GMT')
|
||||
|
||||
@test.support.run_with_tz('Europe/Minsk')
|
||||
def test_formatdate_with_localtime(self):
|
||||
timeval = time.mktime((2011, 1, 1, 18, 0, 0, 6, 1, 0))
|
||||
string = utils.formatdate(timeval, localtime=True)
|
||||
self.assertEqual(string, 'Sat, 01 Jan 2011 18:00:00 +0200')
|
||||
# Minsk moved from +0200 (with DST) to +0300 (without DST) in 2011
|
||||
timeval = time.mktime((2011, 12, 1, 18, 0, 0, 4, 335, 0))
|
||||
string = utils.formatdate(timeval, localtime=True)
|
||||
self.assertEqual(string, 'Thu, 01 Dec 2011 18:00:00 +0300')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue