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
2
third_party/python/Lib/test/audiotests.py
vendored
2
third_party/python/Lib/test/audiotests.py
vendored
|
@ -250,7 +250,7 @@ class AudioTestsWithSourceFile(AudioTests):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.sndfilepath = findfile(cls.sndfilename, subdir='audiodata')
|
||||
cls.sndfilepath = findfile(cls.sndfilename, subdir='/zip/.python/test/audiodata')
|
||||
|
||||
def test_read_params(self):
|
||||
f = self.f = self.module.open(self.sndfilepath)
|
||||
|
|
50
third_party/python/Lib/test/datetimetester.py
vendored
50
third_party/python/Lib/test/datetimetester.py
vendored
|
@ -62,9 +62,6 @@ class TestModule(unittest.TestCase):
|
|||
self.assertEqual(datetime.MAXYEAR, 9999)
|
||||
|
||||
def test_name_cleanup(self):
|
||||
if '_Pure' in self.__class__.__name__:
|
||||
self.skipTest('Only run for Fast C implementation')
|
||||
|
||||
datetime = datetime_module
|
||||
names = set(name for name in dir(datetime)
|
||||
if not name.startswith('__') and not name.endswith('__'))
|
||||
|
@ -73,32 +70,27 @@ class TestModule(unittest.TestCase):
|
|||
'tzinfo', 'sys'])
|
||||
self.assertEqual(names - allowed, set([]))
|
||||
|
||||
def test_divide_and_round(self):
|
||||
if '_Fast' in self.__class__.__name__:
|
||||
self.skipTest('Only run for Pure Python implementation')
|
||||
|
||||
dar = datetime_module._divide_and_round
|
||||
|
||||
self.assertEqual(dar(-10, -3), 3)
|
||||
self.assertEqual(dar(5, -2), -2)
|
||||
|
||||
# four cases: (2 signs of a) x (2 signs of b)
|
||||
self.assertEqual(dar(7, 3), 2)
|
||||
self.assertEqual(dar(-7, 3), -2)
|
||||
self.assertEqual(dar(7, -3), -2)
|
||||
self.assertEqual(dar(-7, -3), 2)
|
||||
|
||||
# ties to even - eight cases:
|
||||
# (2 signs of a) x (2 signs of b) x (even / odd quotient)
|
||||
self.assertEqual(dar(10, 4), 2)
|
||||
self.assertEqual(dar(-10, 4), -2)
|
||||
self.assertEqual(dar(10, -4), -2)
|
||||
self.assertEqual(dar(-10, -4), 2)
|
||||
|
||||
self.assertEqual(dar(6, 4), 2)
|
||||
self.assertEqual(dar(-6, 4), -2)
|
||||
self.assertEqual(dar(6, -4), -2)
|
||||
self.assertEqual(dar(-6, -4), 2)
|
||||
# def test_divide_and_round(self):
|
||||
# if '_Fast' in self.__class__.__name__:
|
||||
# self.skipTest('Only run for Pure Python implementation')
|
||||
# dar = datetime_module._divide_and_round
|
||||
# self.assertEqual(dar(-10, -3), 3)
|
||||
# self.assertEqual(dar(5, -2), -2)
|
||||
# # four cases: (2 signs of a) x (2 signs of b)
|
||||
# self.assertEqual(dar(7, 3), 2)
|
||||
# self.assertEqual(dar(-7, 3), -2)
|
||||
# self.assertEqual(dar(7, -3), -2)
|
||||
# self.assertEqual(dar(-7, -3), 2)
|
||||
# # ties to even - eight cases:
|
||||
# # (2 signs of a) x (2 signs of b) x (even / odd quotient)
|
||||
# self.assertEqual(dar(10, 4), 2)
|
||||
# self.assertEqual(dar(-10, 4), -2)
|
||||
# self.assertEqual(dar(10, -4), -2)
|
||||
# self.assertEqual(dar(-10, -4), 2)
|
||||
# self.assertEqual(dar(6, 4), 2)
|
||||
# self.assertEqual(dar(-6, 4), -2)
|
||||
# self.assertEqual(dar(6, -4), -2)
|
||||
# self.assertEqual(dar(-6, -4), 2)
|
||||
|
||||
|
||||
#############################################################################
|
||||
|
|
1445
third_party/python/Lib/test/mime.types
vendored
1445
third_party/python/Lib/test/mime.types
vendored
File diff suppressed because it is too large
Load diff
50
third_party/python/Lib/test/regrtest.py
vendored
50
third_party/python/Lib/test/regrtest.py
vendored
|
@ -1,50 +0,0 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
"""
|
||||
Script to run Python regression tests.
|
||||
|
||||
Run this script with -h or --help for documentation.
|
||||
"""
|
||||
|
||||
# We import importlib *ASAP* in order to test #15386
|
||||
import importlib
|
||||
|
||||
import os
|
||||
import sys
|
||||
from test.libregrtest import main
|
||||
|
||||
|
||||
# Alias for backward compatibility (just in case)
|
||||
main_in_temp_cwd = main
|
||||
|
||||
|
||||
def _main():
|
||||
global __file__
|
||||
|
||||
# Remove regrtest.py's own directory from the module search path. Despite
|
||||
# the elimination of implicit relative imports, this is still needed to
|
||||
# ensure that submodules of the test package do not inappropriately appear
|
||||
# as top-level modules even when people (or buildbots!) invoke regrtest.py
|
||||
# directly instead of using the -m switch
|
||||
mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
|
||||
i = len(sys.path) - 1
|
||||
while i >= 0:
|
||||
if os.path.abspath(os.path.normpath(sys.path[i])) == mydir:
|
||||
del sys.path[i]
|
||||
else:
|
||||
i -= 1
|
||||
|
||||
# findtestdir() gets the dirname out of __file__, so we have to make it
|
||||
# absolute before changing the working directory.
|
||||
# For example __file__ may be relative when running trace or profile.
|
||||
# See issue #9323.
|
||||
__file__ = os.path.abspath(__file__)
|
||||
|
||||
# sanity check
|
||||
assert __file__ == os.path.abspath(sys.argv[0])
|
||||
|
||||
main()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
_main()
|
17
third_party/python/Lib/test/support/__init__.py
vendored
17
third_party/python/Lib/test/support/__init__.py
vendored
|
@ -40,6 +40,7 @@ try:
|
|||
except ImportError:
|
||||
_thread = None
|
||||
threading = None
|
||||
|
||||
try:
|
||||
import multiprocessing.process
|
||||
except ImportError:
|
||||
|
@ -70,6 +71,12 @@ try:
|
|||
except ImportError:
|
||||
resource = None
|
||||
|
||||
# if __name__ == 'PYOBJ.COM':
|
||||
# import bz2
|
||||
# import zlib
|
||||
# import resource
|
||||
# import multiprocessing.process
|
||||
|
||||
__all__ = [
|
||||
# globals
|
||||
"PIPE_MAX_SIZE", "verbose", "max_memuse", "use_resources", "failfast",
|
||||
|
@ -874,7 +881,10 @@ if sys.platform == 'darwin':
|
|||
# In Mac OS X's VFS API file names are, by definition, canonically
|
||||
# decomposed Unicode, encoded using UTF-8. See QA1173:
|
||||
# http://developer.apple.com/mac/library/qa/qa2001/qa1173.html
|
||||
import unicodedata
|
||||
try:
|
||||
import unicodedata
|
||||
except ImportError:
|
||||
pass
|
||||
TESTFN_UNICODE = unicodedata.normalize('NFD', TESTFN_UNICODE)
|
||||
TESTFN_ENCODING = sys.getfilesystemencoding()
|
||||
|
||||
|
@ -2550,7 +2560,10 @@ class SuppressCrashReport:
|
|||
# see http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621.aspx
|
||||
# GetErrorMode is not available on Windows XP and Windows Server 2003,
|
||||
# but SetErrorMode returns the previous value, so we can use that
|
||||
import ctypes
|
||||
try:
|
||||
import ctypes
|
||||
except ImportError:
|
||||
pass
|
||||
self._k32 = ctypes.windll.kernel32
|
||||
SEM_NOGPFAULTERRORBOX = 0x02
|
||||
self.old_value = self._k32.SetErrorMode(SEM_NOGPFAULTERRORBOX)
|
||||
|
|
2
third_party/python/Lib/test/test_aifc.py
vendored
2
third_party/python/Lib/test/test_aifc.py
vendored
|
@ -148,7 +148,7 @@ class AifcMiscTest(audiotests.AudioTests, unittest.TestCase):
|
|||
def test_skipunknown(self):
|
||||
#Issue 2245
|
||||
#This file contains chunk types aifc doesn't recognize.
|
||||
self.f = aifc.open(findfile('Sine-1000Hz-300ms.aif'))
|
||||
self.f = aifc.open('/zip/.python/test/Sine-1000Hz-300ms.aif')
|
||||
|
||||
def test_close_opened_files_on_error(self):
|
||||
non_aifc_file = findfile('pluck-pcm8.wav', subdir='audiodata')
|
||||
|
|
|
@ -8,9 +8,6 @@ import sysconfig
|
|||
import unittest
|
||||
|
||||
|
||||
# This test is only relevant for from-source builds of Python.
|
||||
if not sysconfig.is_python_build():
|
||||
raise unittest.SkipTest('test irrelevant for an installed Python')
|
||||
|
||||
src_base = dirname(dirname(dirname(__file__)))
|
||||
parser_dir = os.path.join(src_base, 'Parser')
|
||||
|
|
34
third_party/python/Lib/test/test_base64.py
vendored
34
third_party/python/Lib/test/test_base64.py
vendored
|
@ -652,39 +652,5 @@ class BaseXYTestCase(unittest.TestCase):
|
|||
self.assertTrue(issubclass(binascii.Error, ValueError))
|
||||
|
||||
|
||||
class TestMain(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
if os.path.exists(support.TESTFN):
|
||||
os.unlink(support.TESTFN)
|
||||
|
||||
def get_output(self, *args):
|
||||
return script_helper.assert_python_ok('-m', 'base64', *args).out
|
||||
|
||||
def test_encode_decode(self):
|
||||
output = self.get_output('-t')
|
||||
self.assertSequenceEqual(output.splitlines(), (
|
||||
b"b'Aladdin:open sesame'",
|
||||
br"b'QWxhZGRpbjpvcGVuIHNlc2FtZQ==\n'",
|
||||
b"b'Aladdin:open sesame'",
|
||||
))
|
||||
|
||||
def test_encode_file(self):
|
||||
with open(support.TESTFN, 'wb') as fp:
|
||||
fp.write(b'a\xffb\n')
|
||||
output = self.get_output('-e', support.TESTFN)
|
||||
self.assertEqual(output.rstrip(), b'Yf9iCg==')
|
||||
|
||||
def test_encode_from_stdin(self):
|
||||
with script_helper.spawn_python('-m', 'base64', '-e') as proc:
|
||||
out, err = proc.communicate(b'a\xffb\n')
|
||||
self.assertEqual(out.rstrip(), b'Yf9iCg==')
|
||||
self.assertIsNone(err)
|
||||
|
||||
def test_decode(self):
|
||||
with open(support.TESTFN, 'wb') as fp:
|
||||
fp.write(b'Yf9iCg==')
|
||||
output = self.get_output('-d', support.TESTFN)
|
||||
self.assertEqual(output.rstrip(), b'a\xffb')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
1
third_party/python/Lib/test/test_bigmem.py
vendored
1
third_party/python/Lib/test/test_bigmem.py
vendored
|
@ -14,6 +14,7 @@ from test.support import bigmemtest, _1G, _2G, _4G
|
|||
import unittest
|
||||
import operator
|
||||
import sys
|
||||
from encodings import raw_unicode_escape
|
||||
|
||||
# These tests all use one of the bigmemtest decorators to indicate how much
|
||||
# memory they use and how much memory they need to be even meaningful. The
|
||||
|
|
3
third_party/python/Lib/test/test_builtin.py
vendored
3
third_party/python/Lib/test/test_builtin.py
vendored
|
@ -2,6 +2,7 @@
|
|||
|
||||
import ast
|
||||
import builtins
|
||||
import _cosmo
|
||||
import collections
|
||||
import decimal
|
||||
import fractions
|
||||
|
@ -1028,6 +1029,8 @@ class BuiltinTest(unittest.TestCase):
|
|||
os.environ.clear()
|
||||
os.environ.update(old_environ)
|
||||
|
||||
@unittest.skipIf(_cosmo.MODE in ('tiny', 'rel'),
|
||||
"fails on missing .py file in rel omed")
|
||||
def test_open_non_inheritable(self):
|
||||
fileobj = open(__file__)
|
||||
with fileobj:
|
||||
|
|
3
third_party/python/Lib/test/test_bytes.py
vendored
3
third_party/python/Lib/test/test_bytes.py
vendored
|
@ -9,6 +9,7 @@ import os
|
|||
import re
|
||||
import sys
|
||||
import copy
|
||||
import _cosmo
|
||||
import functools
|
||||
import pickle
|
||||
import tempfile
|
||||
|
@ -846,6 +847,8 @@ class BytesTest(BaseBytesTest, unittest.TestCase):
|
|||
with self.assertRaisesRegex(TypeError, msg):
|
||||
b'python'['a']
|
||||
|
||||
@unittest.skipIf(_cosmo.MODE in ('tiny', 'rel'),
|
||||
"fails on missing .py file in rel omed")
|
||||
def test_buffer_is_readonly(self):
|
||||
fd = os.open(__file__, os.O_RDONLY)
|
||||
with open(fd, "rb", buffering=0) as f:
|
||||
|
|
4
third_party/python/Lib/test/test_bz2.py
vendored
4
third_party/python/Lib/test/test_bz2.py
vendored
|
@ -14,6 +14,7 @@ import sys
|
|||
from test.support import unlink
|
||||
import _compression
|
||||
import sys
|
||||
from encodings import utf_16_le
|
||||
|
||||
try:
|
||||
import _thread
|
||||
|
@ -21,8 +22,7 @@ try:
|
|||
except ImportError:
|
||||
threading = None
|
||||
|
||||
# Skip tests if the bz2 module doesn't exist.
|
||||
bz2 = support.import_module('bz2')
|
||||
import bz2
|
||||
from bz2 import BZ2File, BZ2Compressor, BZ2Decompressor
|
||||
|
||||
has_cmdline_bunzip2 = None
|
||||
|
|
|
@ -4,6 +4,7 @@ import sys
|
|||
import test.support
|
||||
import unicodedata
|
||||
import unittest
|
||||
from encodings import raw_unicode_escape
|
||||
|
||||
class PosReturn:
|
||||
# this can be used for configurable callbacks
|
||||
|
|
123
third_party/python/Lib/test/test_codecs.py
vendored
123
third_party/python/Lib/test/test_codecs.py
vendored
|
@ -8,6 +8,129 @@ import encodings
|
|||
|
||||
from test import support
|
||||
|
||||
from encodings import (
|
||||
aliases,
|
||||
base64_codec,
|
||||
big5,
|
||||
big5hkscs,
|
||||
bz2_codec,
|
||||
charmap,
|
||||
cp037,
|
||||
cp1006,
|
||||
cp1026,
|
||||
cp1125,
|
||||
cp1140,
|
||||
cp1250,
|
||||
cp1251,
|
||||
cp1252,
|
||||
cp1253,
|
||||
cp1254,
|
||||
cp1255,
|
||||
cp1256,
|
||||
cp1257,
|
||||
cp1258,
|
||||
cp273,
|
||||
cp424,
|
||||
cp437,
|
||||
cp500,
|
||||
cp720,
|
||||
cp737,
|
||||
cp775,
|
||||
cp850,
|
||||
cp852,
|
||||
cp855,
|
||||
cp856,
|
||||
cp857,
|
||||
cp858,
|
||||
cp860,
|
||||
cp861,
|
||||
cp862,
|
||||
cp863,
|
||||
cp864,
|
||||
cp865,
|
||||
cp866,
|
||||
cp869,
|
||||
cp874,
|
||||
cp875,
|
||||
cp932,
|
||||
cp949,
|
||||
cp950,
|
||||
euc_jis_2004,
|
||||
euc_jisx0213,
|
||||
euc_jp,
|
||||
euc_kr,
|
||||
gb18030,
|
||||
gb2312,
|
||||
gbk,
|
||||
hex_codec,
|
||||
hp_roman8,
|
||||
hz,
|
||||
idna,
|
||||
iso2022_jp,
|
||||
iso2022_jp_1,
|
||||
iso2022_jp_2,
|
||||
iso2022_jp_2004,
|
||||
iso2022_jp_3,
|
||||
iso2022_jp_ext,
|
||||
iso2022_kr,
|
||||
iso8859_1,
|
||||
iso8859_10,
|
||||
iso8859_11,
|
||||
iso8859_13,
|
||||
iso8859_14,
|
||||
iso8859_15,
|
||||
iso8859_16,
|
||||
iso8859_2,
|
||||
iso8859_3,
|
||||
iso8859_4,
|
||||
iso8859_5,
|
||||
iso8859_6,
|
||||
iso8859_7,
|
||||
iso8859_8,
|
||||
iso8859_9,
|
||||
johab,
|
||||
koi8_r,
|
||||
koi8_t,
|
||||
koi8_u,
|
||||
kz1048,
|
||||
latin_1,
|
||||
mac_arabic,
|
||||
mac_centeuro,
|
||||
mac_croatian,
|
||||
mac_cyrillic,
|
||||
mac_farsi,
|
||||
mac_greek,
|
||||
mac_iceland,
|
||||
mac_latin2,
|
||||
mac_roman,
|
||||
mac_romanian,
|
||||
mac_turkish,
|
||||
palmos,
|
||||
ptcp154,
|
||||
punycode,
|
||||
quopri_codec,
|
||||
raw_unicode_escape,
|
||||
rot_13,
|
||||
shift_jis,
|
||||
shift_jis_2004,
|
||||
shift_jisx0213,
|
||||
tis_620,
|
||||
undefined,
|
||||
unicode_escape,
|
||||
unicode_internal,
|
||||
utf_16,
|
||||
utf_16_be,
|
||||
utf_16_le,
|
||||
utf_32,
|
||||
utf_32_be,
|
||||
utf_32_le,
|
||||
utf_7,
|
||||
utf_8,
|
||||
utf_8_sig,
|
||||
uu_codec,
|
||||
zlib_codec,
|
||||
)
|
||||
|
||||
try:
|
||||
import ctypes
|
||||
except ImportError:
|
||||
|
|
12
third_party/python/Lib/test/test_decimal.py
vendored
12
third_party/python/Lib/test/test_decimal.py
vendored
|
@ -46,6 +46,9 @@ try:
|
|||
except ImportError:
|
||||
threading = None
|
||||
|
||||
if __name__ == 'PYOBJ.COM':
|
||||
import decimal
|
||||
import fractions
|
||||
|
||||
C = import_fresh_module('decimal', fresh=['_decimal'])
|
||||
P = import_fresh_module('decimal', blocked=['_decimal'])
|
||||
|
@ -108,14 +111,7 @@ def init(m):
|
|||
)
|
||||
m.setcontext(DefaultTestContext)
|
||||
|
||||
TESTDATADIR = 'decimaltestdata'
|
||||
if __name__ == '__main__':
|
||||
file = sys.argv[0]
|
||||
else:
|
||||
file = __file__
|
||||
testdir = os.path.dirname(file) or os.curdir
|
||||
directory = testdir + os.sep + TESTDATADIR + os.sep
|
||||
|
||||
directory = '/zip/.python/test/decimaltestdata'
|
||||
skip_expected = not os.path.isdir(directory)
|
||||
|
||||
# Make sure it actually raises errors when not expected and caught in flags
|
||||
|
|
2
third_party/python/Lib/test/test_difflib.py
vendored
2
third_party/python/Lib/test/test_difflib.py
vendored
|
@ -235,7 +235,7 @@ class TestSFpatches(unittest.TestCase):
|
|||
#with open('test_difflib_expect.html','w') as fp:
|
||||
# fp.write(actual)
|
||||
|
||||
with open(findfile('test_difflib_expect.html')) as fp:
|
||||
with open(findfile('/zip/.python/test/test_difflib_expect.html')) as fp:
|
||||
self.assertEqual(actual, fp.read())
|
||||
|
||||
def test_recursion_limit(self):
|
||||
|
|
|
@ -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()
|
||||
|
|
4
third_party/python/Lib/test/test_fcntl.py
vendored
4
third_party/python/Lib/test/test_fcntl.py
vendored
|
@ -11,6 +11,10 @@ from test.support import (verbose, TESTFN, unlink, run_unittest, import_module,
|
|||
# Skip test if no fcntl module.
|
||||
fcntl = import_module('fcntl')
|
||||
|
||||
if __name__ == 'PYOBJ.COM':
|
||||
import fcntl
|
||||
import termios
|
||||
|
||||
|
||||
# TODO - Write tests for flock() and lockf().
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ except ImportError:
|
|||
|
||||
from io import BytesIO, StringIO
|
||||
from fileinput import FileInput, hook_encoded
|
||||
from encodings import utf_7
|
||||
|
||||
from test.support import verbose, TESTFN, check_warnings
|
||||
from test.support import unlink as safe_unlink
|
||||
|
|
|
@ -18,10 +18,11 @@ except ImportError:
|
|||
threading = None
|
||||
|
||||
import functools
|
||||
if __name__ == 'PYOBJ.COM':
|
||||
import decimal
|
||||
|
||||
py_functools = support.import_fresh_module('functools', blocked=['_functools'])
|
||||
c_functools = support.import_fresh_module('functools', fresh=['_functools'])
|
||||
|
||||
decimal = support.import_fresh_module('decimal', fresh=['_decimal'])
|
||||
|
||||
@contextlib.contextmanager
|
||||
|
|
2
third_party/python/Lib/test/test_gzip.py
vendored
2
third_party/python/Lib/test/test_gzip.py
vendored
|
@ -9,12 +9,14 @@ import pathlib
|
|||
import struct
|
||||
import sys
|
||||
import unittest
|
||||
from encodings import utf_16
|
||||
from subprocess import PIPE, Popen
|
||||
from test import support
|
||||
from test.support import _4G, bigmemtest
|
||||
from test.support.script_helper import assert_python_ok
|
||||
|
||||
gzip = support.import_module('gzip')
|
||||
if __name__ == 'PYOBJ.COM': import gzip
|
||||
|
||||
data1 = b""" int length=DEFAULTALLOC, err = Z_OK;
|
||||
PyObject *RetVal;
|
||||
|
|
23
third_party/python/Lib/test/test_hashlib.py
vendored
23
third_party/python/Lib/test/test_hashlib.py
vendored
|
@ -47,15 +47,8 @@ def hexstr(s):
|
|||
return r
|
||||
|
||||
|
||||
URL = "http://www.pythontest.net/hashlib/{}.txt"
|
||||
|
||||
def read_vectors(hash_name):
|
||||
url = URL.format(hash_name)
|
||||
try:
|
||||
testdata = support.open_urlresource(url)
|
||||
except (OSError, HTTPException):
|
||||
raise unittest.SkipTest("Could not retrieve {}".format(url))
|
||||
with testdata:
|
||||
with open('/zip/.python/test/%s.txt' % (hash_name)) as testdata:
|
||||
for line in testdata:
|
||||
line = line.strip()
|
||||
if line.startswith('#') or not line:
|
||||
|
@ -66,13 +59,13 @@ def read_vectors(hash_name):
|
|||
|
||||
|
||||
class HashLibTestCase(unittest.TestCase):
|
||||
shakes = {'shake_128', 'shake_256'}
|
||||
supported_hash_names = ( 'md5', 'MD5', 'sha1', 'SHA1',
|
||||
'sha224', 'SHA224', 'sha256', 'SHA256',
|
||||
'sha384', 'SHA384', 'sha512', 'SHA512',
|
||||
'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512',
|
||||
'shake_128', 'shake_256')
|
||||
|
||||
shakes = {'shake_128', 'shake_256'}
|
||||
# 'sha3_224', 'sha3_256', 'sha3_384',
|
||||
# 'sha3_512', 'shake_128', 'shake_256'
|
||||
)
|
||||
|
||||
# Issue #14693: fallback modules are always compiled under POSIX
|
||||
_warn_on_extension_import = os.name == 'posix' or COMPILED_WITH_PYDEBUG
|
||||
|
@ -109,10 +102,10 @@ class HashLibTestCase(unittest.TestCase):
|
|||
if _hashlib:
|
||||
# These two algorithms should always be present when this module
|
||||
# is compiled. If not, something was compiled wrong.
|
||||
self.assertTrue(hasattr(_hashlib, 'openssl_md5'))
|
||||
self.assertTrue(hasattr(_hashlib, 'openssl_sha1'))
|
||||
self.assertTrue(hasattr(_hashlib, 'mbedtls_md5'))
|
||||
self.assertTrue(hasattr(_hashlib, 'mbedtls_sha1'))
|
||||
for algorithm, constructors in self.constructors_to_test.items():
|
||||
constructor = getattr(_hashlib, 'openssl_'+algorithm, None)
|
||||
constructor = getattr(_hashlib, 'mbedtls_'+algorithm, None)
|
||||
if constructor:
|
||||
constructors.add(constructor)
|
||||
|
||||
|
|
1
third_party/python/Lib/test/test_io.py
vendored
1
third_party/python/Lib/test/test_io.py
vendored
|
@ -32,6 +32,7 @@ import time
|
|||
import unittest
|
||||
import warnings
|
||||
import weakref
|
||||
from encodings import hex_codec, rot_13, quopri_codec
|
||||
from collections import deque, UserList
|
||||
from itertools import cycle, count
|
||||
from test import support
|
||||
|
|
5
third_party/python/Lib/test/test_ioctl.py
vendored
5
third_party/python/Lib/test/test_ioctl.py
vendored
|
@ -2,10 +2,15 @@ import array
|
|||
import unittest
|
||||
from test.support import import_module, get_attribute
|
||||
import os, struct
|
||||
|
||||
fcntl = import_module('fcntl')
|
||||
termios = import_module('termios')
|
||||
get_attribute(termios, 'TIOCGPGRP') #Can't run tests without this feature
|
||||
|
||||
if __name__ == 'PYOBJ.COM':
|
||||
import fcntl
|
||||
import termios
|
||||
|
||||
try:
|
||||
tty = open("/dev/tty", "rb")
|
||||
except OSError:
|
||||
|
|
16
third_party/python/Lib/test/test_itertools.py
vendored
16
third_party/python/Lib/test/test_itertools.py
vendored
|
@ -14,6 +14,8 @@ import struct
|
|||
maxsize = support.MAX_Py_ssize_t
|
||||
minsize = -maxsize-1
|
||||
|
||||
# [jart] test disabled for usingh a laugh out loud amount of cpu and memory
|
||||
|
||||
def lzip(*args):
|
||||
return list(zip(*args))
|
||||
|
||||
|
@ -196,6 +198,7 @@ class TestBasicOps(unittest.TestCase):
|
|||
it.__setstate__((iter(['abc', 'def']), iter(['ghi'])))
|
||||
self.assertEqual(list(it), ['ghi', 'a', 'b', 'c', 'd', 'e', 'f'])
|
||||
|
||||
@unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota')
|
||||
def test_combinations(self):
|
||||
self.assertRaises(TypeError, combinations, 'abc') # missing r argument
|
||||
self.assertRaises(TypeError, combinations, 'abc', 2, 1) # too many arguments
|
||||
|
@ -277,6 +280,7 @@ class TestBasicOps(unittest.TestCase):
|
|||
self.pickletest(proto, combinations(values, r)) # test pickling
|
||||
|
||||
@support.bigaddrspacetest
|
||||
@unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota')
|
||||
def test_combinations_overflow(self):
|
||||
with self.assertRaises((OverflowError, MemoryError)):
|
||||
combinations("AA", 2**29)
|
||||
|
@ -287,6 +291,7 @@ class TestBasicOps(unittest.TestCase):
|
|||
self.assertEqual(len(set(map(id, combinations('abcde', 3)))), 1)
|
||||
self.assertNotEqual(len(set(map(id, list(combinations('abcde', 3))))), 1)
|
||||
|
||||
@unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota')
|
||||
def test_combinations_with_replacement(self):
|
||||
cwr = combinations_with_replacement
|
||||
self.assertRaises(TypeError, cwr, 'abc') # missing r argument
|
||||
|
@ -364,17 +369,20 @@ class TestBasicOps(unittest.TestCase):
|
|||
self.pickletest(proto, cwr(values,r)) # test pickling
|
||||
|
||||
@support.bigaddrspacetest
|
||||
@unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota')
|
||||
def test_combinations_with_replacement_overflow(self):
|
||||
with self.assertRaises((OverflowError, MemoryError)):
|
||||
combinations_with_replacement("AA", 2**30)
|
||||
|
||||
# Test implementation detail: tuple re-use
|
||||
@unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota')
|
||||
@support.impl_detail("tuple reuse is specific to CPython")
|
||||
def test_combinations_with_replacement_tuple_reuse(self):
|
||||
cwr = combinations_with_replacement
|
||||
self.assertEqual(len(set(map(id, cwr('abcde', 3)))), 1)
|
||||
self.assertNotEqual(len(set(map(id, list(cwr('abcde', 3))))), 1)
|
||||
|
||||
@unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota')
|
||||
def test_permutations(self):
|
||||
self.assertRaises(TypeError, permutations) # too few arguments
|
||||
self.assertRaises(TypeError, permutations, 'abc', 2, 1) # too many arguments
|
||||
|
@ -438,16 +446,19 @@ class TestBasicOps(unittest.TestCase):
|
|||
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
|
||||
self.pickletest(proto, permutations(values, r)) # test pickling
|
||||
|
||||
@unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota')
|
||||
@support.bigaddrspacetest
|
||||
def test_permutations_overflow(self):
|
||||
with self.assertRaises((OverflowError, MemoryError)):
|
||||
permutations("A", 2**30)
|
||||
|
||||
@unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota')
|
||||
@support.impl_detail("tuple reuse is specific to CPython")
|
||||
def test_permutations_tuple_reuse(self):
|
||||
self.assertEqual(len(set(map(id, permutations('abcde', 3)))), 1)
|
||||
self.assertNotEqual(len(set(map(id, list(permutations('abcde', 3))))), 1)
|
||||
|
||||
@unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota')
|
||||
def test_combinatorics(self):
|
||||
# Test relationships between product(), permutations(),
|
||||
# combinations() and combinations_with_replacement().
|
||||
|
@ -1508,6 +1519,7 @@ class TestExamples(unittest.TestCase):
|
|||
self.assertEqual(list(combinations(range(4), 3)),
|
||||
[(0,1,2), (0,1,3), (0,2,3), (1,2,3)])
|
||||
|
||||
@unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota')
|
||||
def test_combinations_with_replacement(self):
|
||||
self.assertEqual(list(combinations_with_replacement('ABC', 2)),
|
||||
[('A','A'), ('A','B'), ('A','C'), ('B','B'), ('B','C'), ('C','C')])
|
||||
|
@ -2023,6 +2035,7 @@ class RegressionTests(unittest.TestCase):
|
|||
self.assertRaises(AssertionError, list, cycle(gen1()))
|
||||
self.assertEqual(hist, [0,1])
|
||||
|
||||
@unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota')
|
||||
def test_long_chain_of_empty_iterables(self):
|
||||
# Make sure itertools.chain doesn't run into recursion limits when
|
||||
# dealing with long chains of empty iterables. Even with a high
|
||||
|
@ -2082,12 +2095,14 @@ class SizeofTest(unittest.TestCase):
|
|||
check(product('ab', '12'), basesize + 2 * self.ssize_t)
|
||||
check(product(*(('abc',) * 10)), basesize + 10 * self.ssize_t)
|
||||
|
||||
@unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota')
|
||||
def test_combinations_sizeof(self):
|
||||
basesize = support.calcobjsize('3Pni')
|
||||
check = self.check_sizeof
|
||||
check(combinations('abcd', 3), basesize + 3 * self.ssize_t)
|
||||
check(combinations(range(10), 4), basesize + 4 * self.ssize_t)
|
||||
|
||||
@unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota')
|
||||
def test_combinations_with_replacement_sizeof(self):
|
||||
cwr = combinations_with_replacement
|
||||
basesize = support.calcobjsize('3Pni')
|
||||
|
@ -2095,6 +2110,7 @@ class SizeofTest(unittest.TestCase):
|
|||
check(cwr('abcd', 3), basesize + 3 * self.ssize_t)
|
||||
check(cwr(range(10), 4), basesize + 4 * self.ssize_t)
|
||||
|
||||
@unittest.skipIf(sys.platform == 'cosmo', 'exceeds cpu quota')
|
||||
def test_permutations_sizeof(self):
|
||||
basesize = support.calcobjsize('4Pni')
|
||||
check = self.check_sizeof
|
||||
|
|
1
third_party/python/Lib/test/test_lzma.py
vendored
1
third_party/python/Lib/test/test_lzma.py
vendored
|
@ -7,6 +7,7 @@ import random
|
|||
import sys
|
||||
from test import support
|
||||
import unittest
|
||||
from encodings import utf_16_le
|
||||
|
||||
from test.support import (
|
||||
_4G, TESTFN, import_module, bigmemtest, run_unittest, unlink
|
||||
|
|
3
third_party/python/Lib/test/test_marshal.py
vendored
3
third_party/python/Lib/test/test_marshal.py
vendored
|
@ -12,6 +12,9 @@ try:
|
|||
except ImportError:
|
||||
_testcapi = None
|
||||
|
||||
if __name__ == 'PYOBJ.COM':
|
||||
import _testcapi
|
||||
|
||||
class HelperMixin:
|
||||
def helper(self, sample, *extra):
|
||||
new = marshal.loads(marshal.dumps(sample, *extra))
|
||||
|
|
10
third_party/python/Lib/test/test_math.py
vendored
10
third_party/python/Lib/test/test_math.py
vendored
|
@ -22,14 +22,8 @@ FLOAT_MAX = sys.float_info.max
|
|||
x, y = 1e16, 2.9999 # use temporary values to defeat peephole optimizer
|
||||
HAVE_DOUBLE_ROUNDING = (x + y == 1e16 + 4)
|
||||
|
||||
# locate file with test values
|
||||
if __name__ == '__main__':
|
||||
file = sys.argv[0]
|
||||
else:
|
||||
file = __file__
|
||||
test_dir = os.path.dirname(file) or os.curdir
|
||||
math_testcases = os.path.join(test_dir, 'math_testcases.txt')
|
||||
test_file = os.path.join(test_dir, 'cmath_testcases.txt')
|
||||
math_testcases = '/zip/.python/test/math_testcases.txt'
|
||||
test_file = '/zip/.python/test/cmath_testcases.txt'
|
||||
|
||||
|
||||
def to_ulps(x):
|
||||
|
|
1
third_party/python/Lib/test/test_mmap.py
vendored
1
third_party/python/Lib/test/test_mmap.py
vendored
|
@ -10,6 +10,7 @@ import weakref
|
|||
|
||||
# Skip test if we can't import mmap.
|
||||
mmap = import_module('mmap')
|
||||
if __name__ == 'PYOBJ.COM': import mmap
|
||||
|
||||
PAGESIZE = mmap.PAGESIZE
|
||||
|
||||
|
|
74
third_party/python/Lib/test/test_robotparser.py
vendored
74
third_party/python/Lib/test/test_robotparser.py
vendored
|
@ -285,79 +285,5 @@ class RobotHandler(BaseHTTPRequestHandler):
|
|||
def log_message(self, format, *args):
|
||||
pass
|
||||
|
||||
|
||||
@unittest.skipUnless(threading, 'threading required for this test')
|
||||
class PasswordProtectedSiteTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.server = HTTPServer((support.HOST, 0), RobotHandler)
|
||||
|
||||
self.t = threading.Thread(
|
||||
name='HTTPServer serving',
|
||||
target=self.server.serve_forever,
|
||||
# Short poll interval to make the test finish quickly.
|
||||
# Time between requests is short enough that we won't wake
|
||||
# up spuriously too many times.
|
||||
kwargs={'poll_interval':0.01})
|
||||
self.t.daemon = True # In case this function raises.
|
||||
self.t.start()
|
||||
|
||||
def tearDown(self):
|
||||
self.server.shutdown()
|
||||
self.t.join()
|
||||
self.server.server_close()
|
||||
|
||||
@support.reap_threads
|
||||
def testPasswordProtectedSite(self):
|
||||
addr = self.server.server_address
|
||||
url = 'http://' + support.HOST + ':' + str(addr[1])
|
||||
robots_url = url + "/robots.txt"
|
||||
parser = urllib.robotparser.RobotFileParser()
|
||||
parser.set_url(url)
|
||||
parser.read()
|
||||
self.assertFalse(parser.can_fetch("*", robots_url))
|
||||
|
||||
|
||||
class NetworkTestCase(unittest.TestCase):
|
||||
|
||||
base_url = 'http://www.pythontest.net/'
|
||||
robots_txt = '{}elsewhere/robots.txt'.format(base_url)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
support.requires('network')
|
||||
with support.transient_internet(cls.base_url):
|
||||
cls.parser = urllib.robotparser.RobotFileParser(cls.robots_txt)
|
||||
cls.parser.read()
|
||||
|
||||
def url(self, path):
|
||||
return '{}{}{}'.format(
|
||||
self.base_url, path, '/' if not os.path.splitext(path)[1] else ''
|
||||
)
|
||||
|
||||
def test_basic(self):
|
||||
self.assertFalse(self.parser.disallow_all)
|
||||
self.assertFalse(self.parser.allow_all)
|
||||
self.assertGreater(self.parser.mtime(), 0)
|
||||
self.assertFalse(self.parser.crawl_delay('*'))
|
||||
self.assertFalse(self.parser.request_rate('*'))
|
||||
|
||||
def test_can_fetch(self):
|
||||
self.assertTrue(self.parser.can_fetch('*', self.url('elsewhere')))
|
||||
self.assertFalse(self.parser.can_fetch('Nutch', self.base_url))
|
||||
self.assertFalse(self.parser.can_fetch('Nutch', self.url('brian')))
|
||||
self.assertFalse(self.parser.can_fetch('Nutch', self.url('webstats')))
|
||||
self.assertFalse(self.parser.can_fetch('*', self.url('webstats')))
|
||||
self.assertTrue(self.parser.can_fetch('*', self.base_url))
|
||||
|
||||
def test_read_404(self):
|
||||
parser = urllib.robotparser.RobotFileParser(self.url('i-robot.txt'))
|
||||
parser.read()
|
||||
self.assertTrue(parser.allow_all)
|
||||
self.assertFalse(parser.disallow_all)
|
||||
self.assertEqual(parser.mtime(), 0)
|
||||
self.assertIsNone(parser.crawl_delay('*'))
|
||||
self.assertIsNone(parser.request_rate('*'))
|
||||
|
||||
if __name__=='__main__':
|
||||
unittest.main()
|
||||
|
|
14
third_party/python/Lib/test/test_sax.py
vendored
14
third_party/python/Lib/test/test_sax.py
vendored
|
@ -24,8 +24,18 @@ from urllib.error import URLError
|
|||
from test import support
|
||||
from test.support import findfile, run_unittest, TESTFN
|
||||
|
||||
TEST_XMLFILE = findfile("test.xml", subdir="xmltestdata")
|
||||
TEST_XMLFILE_OUT = findfile("test.xml.out", subdir="xmltestdata")
|
||||
from encodings import (
|
||||
utf_8_sig,
|
||||
utf_16,
|
||||
utf_16_be,
|
||||
utf_16_le,
|
||||
utf_32,
|
||||
utf_32_be,
|
||||
utf_32_le,
|
||||
)
|
||||
|
||||
TEST_XMLFILE = "/zip/.python/test/xmltestdata/test.xml"
|
||||
TEST_XMLFILE_OUT = "/zip/.python/test/xmltestdata/test.xml.out"
|
||||
try:
|
||||
TEST_XMLFILE.encode("utf-8")
|
||||
TEST_XMLFILE_OUT.encode("utf-8")
|
||||
|
|
|
@ -7,6 +7,7 @@ import os
|
|||
import sys
|
||||
import subprocess
|
||||
import tempfile
|
||||
from encodings import cp1252
|
||||
|
||||
class MiscSourceEncodingTest(unittest.TestCase):
|
||||
|
||||
|
|
10
third_party/python/Lib/test/test_stat.py
vendored
10
third_party/python/Lib/test/test_stat.py
vendored
|
@ -6,6 +6,9 @@ from test.support import TESTFN, import_fresh_module
|
|||
c_stat = import_fresh_module('stat', fresh=['_stat'])
|
||||
py_stat = import_fresh_module('stat', blocked=['_stat'])
|
||||
|
||||
assert c_stat
|
||||
assert py_stat
|
||||
|
||||
class TestFilemode:
|
||||
statmod = None
|
||||
|
||||
|
@ -85,9 +88,10 @@ class TestFilemode:
|
|||
|
||||
def get_mode(self, fname=TESTFN, lstat=True):
|
||||
if lstat:
|
||||
st_mode = os.lstat(fname).st_mode
|
||||
st_mode = os.lstat(fname).st_mode
|
||||
else:
|
||||
st_mode = os.stat(fname).st_mode
|
||||
print('ugh',self.statmod)
|
||||
modestr = self.statmod.filemode(st_mode)
|
||||
return st_mode, modestr
|
||||
|
||||
|
@ -232,3 +236,7 @@ class TestFilemodePyStat(TestFilemode, unittest.TestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
if __name__ == 'PYOBJ.COM':
|
||||
import stat
|
||||
import _stat
|
||||
|
|
1
third_party/python/Lib/test/test_tempfile.py
vendored
1
third_party/python/Lib/test/test_tempfile.py
vendored
|
@ -13,6 +13,7 @@ from unittest import mock
|
|||
|
||||
import unittest
|
||||
from test import support
|
||||
from encodings import utf_16
|
||||
from test.support import script_helper
|
||||
|
||||
|
||||
|
|
4
third_party/python/Lib/test/test_typing.py
vendored
4
third_party/python/Lib/test/test_typing.py
vendored
|
@ -29,6 +29,10 @@ try:
|
|||
except ImportError:
|
||||
import collections as collections_abc # Fallback for PY3.2.
|
||||
|
||||
if __name__ == 'PYOBJ.COM':
|
||||
import test.ann_module
|
||||
import test.ann_module2
|
||||
import test.ann_module3
|
||||
|
||||
try:
|
||||
import mod_generics_cache
|
||||
|
|
16
third_party/python/Lib/test/test_utf8source.py
vendored
16
third_party/python/Lib/test/test_utf8source.py
vendored
|
@ -14,14 +14,14 @@ class PEP3120Test(unittest.TestCase):
|
|||
b'\\\xd0\x9f'
|
||||
)
|
||||
|
||||
def test_badsyntax(self):
|
||||
try:
|
||||
import test.badsyntax_pep3120
|
||||
except SyntaxError as msg:
|
||||
msg = str(msg).lower()
|
||||
self.assertTrue('utf-8' in msg)
|
||||
else:
|
||||
self.fail("expected exception didn't occur")
|
||||
# def test_badsyntax(self):
|
||||
# try:
|
||||
# import test.badsyntax_pep3120
|
||||
# except SyntaxError as msg:
|
||||
# msg = str(msg).lower()
|
||||
# self.assertTrue('utf-8' in msg)
|
||||
# else:
|
||||
# self.fail("expected exception didn't occur")
|
||||
|
||||
|
||||
class BuiltinCompileTests(unittest.TestCase):
|
||||
|
|
|
@ -16,6 +16,7 @@ import unittest
|
|||
import warnings
|
||||
import weakref
|
||||
|
||||
from encodings import utf_16
|
||||
from itertools import product
|
||||
from test import support
|
||||
from test.support import TESTFN, findfile, import_fresh_module, gc_collect, swap_attr
|
||||
|
|
5
third_party/python/Lib/test/test_zlib.py
vendored
5
third_party/python/Lib/test/test_zlib.py
vendored
|
@ -4,10 +4,9 @@ import binascii
|
|||
import pickle
|
||||
import random
|
||||
import sys
|
||||
import zlib
|
||||
from test.support import bigmemtest, _1G, _4G
|
||||
|
||||
zlib = support.import_module('zlib')
|
||||
|
||||
requires_Compress_copy = unittest.skipUnless(
|
||||
hasattr(zlib.compressobj(), "copy"),
|
||||
'requires Compress.copy()')
|
||||
|
@ -710,6 +709,8 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
|
|||
|
||||
@bigmemtest(size=_1G + 1024 * 1024, memuse=3)
|
||||
def test_big_compress_buffer(self, size):
|
||||
import tracemalloc
|
||||
tracemalloc.start(20)
|
||||
c = zlib.compressobj(1)
|
||||
compress = lambda s: c.compress(s) + c.flush()
|
||||
self.check_big_compress_buffer(size, compress)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue