Skip to content

Commit a53b64e

Browse files
committed
Allow test_bool.py to run
1 parent d999739 commit a53b64e

File tree

2 files changed

+107
-105
lines changed

2 files changed

+107
-105
lines changed

Lib/test/support/__init__.py

Lines changed: 103 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
if __name__ != 'test.support':
44
raise ImportError('support must be imported from the test package')
55

6-
import asyncio.events
6+
# import asyncio.events
77
import collections.abc
88
import contextlib
99
import datetime
1010
import errno
11-
import faulthandler
11+
# import faulthandler
1212
import fnmatch
1313
import functools
14-
import gc
14+
# import gc
1515
import importlib
1616
import importlib.util
1717
import io
18-
import logging.handlers
19-
import nntplib
18+
# import logging.handlers
19+
# import nntplib
2020
import os
2121
import platform
2222
import re
@@ -27,13 +27,13 @@
2727
import subprocess
2828
import sys
2929
import sysconfig
30-
import tempfile
30+
# import tempfile
3131
import _thread
32-
import threading
32+
# import threading
3333
import time
3434
import types
3535
import unittest
36-
import urllib.error
36+
# import urllib.error
3737
import warnings
3838

3939
from .testresult import get_test_runner
@@ -757,22 +757,22 @@ def bind_unix_socket(sock, addr):
757757
sock.close()
758758
raise unittest.SkipTest('cannot bind AF_UNIX sockets')
759759

760-
def _is_ipv6_enabled():
761-
"""Check whether IPv6 is enabled on this host."""
762-
if socket.has_ipv6:
763-
sock = None
764-
try:
765-
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
766-
sock.bind((HOSTv6, 0))
767-
return True
768-
except OSError:
769-
pass
770-
finally:
771-
if sock:
772-
sock.close()
773-
return False
774-
775-
IPV6_ENABLED = _is_ipv6_enabled()
760+
# def _is_ipv6_enabled():
761+
# """Check whether IPv6 is enabled on this host."""
762+
# if socket.has_ipv6:
763+
# sock = None
764+
# try:
765+
# sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
766+
# sock.bind((HOSTv6, 0))
767+
# return True
768+
# except OSError:
769+
# pass
770+
# finally:
771+
# if sock:
772+
# sock.close()
773+
# return False
774+
775+
# IPV6_ENABLED = _is_ipv6_enabled()
776776

777777
def system_must_validate_cert(f):
778778
"""Skip the test on TLS certificate validation failures."""
@@ -801,10 +801,10 @@ def dec(*args, **kwargs):
801801
# for a discussion of this number).
802802
SOCK_MAX_SIZE = 16 * 1024 * 1024 + 1
803803

804-
# decorator for skipping tests on non-IEEE 754 platforms
805-
requires_IEEE_754 = unittest.skipUnless(
806-
float.__getformat__("double").startswith("IEEE"),
807-
"test requires IEEE 754 doubles")
804+
# # decorator for skipping tests on non-IEEE 754 platforms
805+
# requires_IEEE_754 = unittest.skipUnless(
806+
# float.__getformat__("double").startswith("IEEE"),
807+
# "test requires IEEE 754 doubles")
808808

809809
requires_zlib = unittest.skipUnless(zlib, 'requires zlib')
810810

@@ -929,35 +929,35 @@ def dec(*args, **kwargs):
929929
# the byte 0xff. Skip some unicode filename tests.
930930
pass
931931

932-
# TESTFN_UNDECODABLE is a filename (bytes type) that should *not* be able to be
933-
# decoded from the filesystem encoding (in strict mode). It can be None if we
934-
# cannot generate such filename (ex: the latin1 encoding can decode any byte
935-
# sequence). On UNIX, TESTFN_UNDECODABLE can be decoded by os.fsdecode() thanks
936-
# to the surrogateescape error handler (PEP 383), but not from the filesystem
937-
# encoding in strict mode.
938-
TESTFN_UNDECODABLE = None
939-
for name in (
940-
# b'\xff' is not decodable by os.fsdecode() with code page 932. Windows
941-
# accepts it to create a file or a directory, or don't accept to enter to
942-
# such directory (when the bytes name is used). So test b'\xe7' first: it is
943-
# not decodable from cp932.
944-
b'\xe7w\xf0',
945-
# undecodable from ASCII, UTF-8
946-
b'\xff',
947-
# undecodable from iso8859-3, iso8859-6, iso8859-7, cp424, iso8859-8, cp856
948-
# and cp857
949-
b'\xae\xd5'
950-
# undecodable from UTF-8 (UNIX and Mac OS X)
951-
b'\xed\xb2\x80', b'\xed\xb4\x80',
952-
# undecodable from shift_jis, cp869, cp874, cp932, cp1250, cp1251, cp1252,
953-
# cp1253, cp1254, cp1255, cp1257, cp1258
954-
b'\x81\x98',
955-
):
956-
try:
957-
name.decode(TESTFN_ENCODING)
958-
except UnicodeDecodeError:
959-
TESTFN_UNDECODABLE = os.fsencode(TESTFN) + name
960-
break
932+
# # TESTFN_UNDECODABLE is a filename (bytes type) that should *not* be able to be
933+
# # decoded from the filesystem encoding (in strict mode). It can be None if we
934+
# # cannot generate such filename (ex: the latin1 encoding can decode any byte
935+
# # sequence). On UNIX, TESTFN_UNDECODABLE can be decoded by os.fsdecode() thanks
936+
# # to the surrogateescape error handler (PEP 383), but not from the filesystem
937+
# # encoding in strict mode.
938+
# TESTFN_UNDECODABLE = None
939+
# for name in (
940+
# # b'\xff' is not decodable by os.fsdecode() with code page 932. Windows
941+
# # accepts it to create a file or a directory, or don't accept to enter to
942+
# # such directory (when the bytes name is used). So test b'\xe7' first: it is
943+
# # not decodable from cp932.
944+
# b'\xe7w\xf0',
945+
# # undecodable from ASCII, UTF-8
946+
# b'\xff',
947+
# # undecodable from iso8859-3, iso8859-6, iso8859-7, cp424, iso8859-8, cp856
948+
# # and cp857
949+
# b'\xae\xd5'
950+
# # undecodable from UTF-8 (UNIX and Mac OS X)
951+
# b'\xed\xb2\x80', b'\xed\xb4\x80',
952+
# # undecodable from shift_jis, cp869, cp874, cp932, cp1250, cp1251, cp1252,
953+
# # cp1253, cp1254, cp1255, cp1257, cp1258
954+
# b'\x81\x98',
955+
# ):
956+
# try:
957+
# name.decode(TESTFN_ENCODING)
958+
# except UnicodeDecodeError:
959+
# TESTFN_UNDECODABLE = os.fsencode(TESTFN) + name
960+
# break
961961

962962
if FS_NONASCII:
963963
TESTFN_NONASCII = TESTFN + '-' + FS_NONASCII
@@ -2414,33 +2414,33 @@ def optim_args_from_interpreter_flags():
24142414
# Support for assertions about logging.
24152415
#============================================================
24162416

2417-
class TestHandler(logging.handlers.BufferingHandler):
2418-
def __init__(self, matcher):
2419-
# BufferingHandler takes a "capacity" argument
2420-
# so as to know when to flush. As we're overriding
2421-
# shouldFlush anyway, we can set a capacity of zero.
2422-
# You can call flush() manually to clear out the
2423-
# buffer.
2424-
logging.handlers.BufferingHandler.__init__(self, 0)
2425-
self.matcher = matcher
2426-
2427-
def shouldFlush(self):
2428-
return False
2429-
2430-
def emit(self, record):
2431-
self.format(record)
2432-
self.buffer.append(record.__dict__)
2433-
2434-
def matches(self, **kwargs):
2435-
"""
2436-
Look for a saved dict whose keys/values match the supplied arguments.
2437-
"""
2438-
result = False
2439-
for d in self.buffer:
2440-
if self.matcher.matches(d, **kwargs):
2441-
result = True
2442-
break
2443-
return result
2417+
# class TestHandler(logging.handlers.BufferingHandler):
2418+
# def __init__(self, matcher):
2419+
# # BufferingHandler takes a "capacity" argument
2420+
# # so as to know when to flush. As we're overriding
2421+
# # shouldFlush anyway, we can set a capacity of zero.
2422+
# # You can call flush() manually to clear out the
2423+
# # buffer.
2424+
# logging.handlers.BufferingHandler.__init__(self, 0)
2425+
# self.matcher = matcher
2426+
2427+
# def shouldFlush(self):
2428+
# return False
2429+
2430+
# def emit(self, record):
2431+
# self.format(record)
2432+
# self.buffer.append(record.__dict__)
2433+
2434+
# def matches(self, **kwargs):
2435+
# """
2436+
# Look for a saved dict whose keys/values match the supplied arguments.
2437+
# """
2438+
# result = False
2439+
# for d in self.buffer:
2440+
# if self.matcher.matches(d, **kwargs):
2441+
# result = True
2442+
# break
2443+
# return result
24442444

24452445
class Matcher(object):
24462446

@@ -2794,23 +2794,23 @@ def run_in_subinterp(code):
27942794
return _testcapi.run_in_subinterp(code)
27952795

27962796

2797-
def check_free_after_iterating(test, iter, cls, args=()):
2798-
class A(cls):
2799-
def __del__(self):
2800-
nonlocal done
2801-
done = True
2802-
try:
2803-
next(it)
2804-
except StopIteration:
2805-
pass
2797+
# def check_free_after_iterating(test, iter, cls, args=()):
2798+
# class A(cls):
2799+
# def __del__(self):
2800+
# nonlocal done
2801+
# done = True
2802+
# try:
2803+
# next(it)
2804+
# except StopIteration:
2805+
# pass
28062806

2807-
done = False
2808-
it = iter(A(*args))
2809-
# Issue 26494: Shouldn't crash
2810-
test.assertRaises(StopIteration, next, it)
2811-
# The sequence should be deallocated just after the end of iterating
2812-
gc_collect()
2813-
test.assertTrue(done)
2807+
# done = False
2808+
# it = iter(A(*args))
2809+
# # Issue 26494: Shouldn't crash
2810+
# test.assertRaises(StopIteration, next, it)
2811+
# # The sequence should be deallocated just after the end of iterating
2812+
# gc_collect()
2813+
# test.assertTrue(done)
28142814

28152815

28162816
def missing_compiler_executable(cmd_names=[]):
@@ -2994,9 +2994,9 @@ def maybe_get_event_loop_policy():
29942994
"""Return the global event loop policy if one is set, else return None."""
29952995
return asyncio.events._event_loop_policy
29962996

2997-
# Helpers for testing hashing.
2998-
NHASHBITS = sys.hash_info.width # number of bits in hash() result
2999-
assert NHASHBITS in (32, 64)
2997+
# # Helpers for testing hashing.
2998+
# NHASHBITS = sys.hash_info.width # number of bits in hash() result
2999+
# assert NHASHBITS in (32, 64)
30003000

30013001
# Return mean and sdev of number of collisions when tossing nballs balls
30023002
# uniformly at random into nbins bins. By definition, the number of

Lib/test/support/testresult.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def __getId(cls, test):
4343
def startTest(self, test):
4444
super().startTest(test)
4545
self.__e = e = ET.SubElement(self.__suite, 'testcase')
46-
self.__start_time = time.perf_counter()
46+
# self.__start_time = time.perf_counter()
47+
self.__start_time = time.time()
4748
if self.__verbose:
4849
self.stream.write(f'{self.getDescription(test)} ... ')
4950
self.stream.flush()
@@ -57,7 +58,8 @@ def _add_result(self, test, capture=False, **args):
5758
e.set('status', args.pop('status', 'run'))
5859
e.set('result', args.pop('result', 'completed'))
5960
if self.__start_time:
60-
e.set('time', f'{time.perf_counter() - self.__start_time:0.6f}')
61+
# e.set('time', f'{time.perf_counter() - self.__start_time:0.6f}')
62+
e.set('time', f'{time.time() - self.__start_time}')
6163

6264
if capture:
6365
if self._stdout_buffer is not None:

0 commit comments

Comments
 (0)