tests.
-:mod:`test.test_support` --- Utility functions for tests
+:mod:`test.support` --- Utility functions for tests
========================================================
-.. module:: test.test_support
+.. module:: test.support
:synopsis: Support for Python regression tests.
-The :mod:`test.test_support` module provides support for Python's regression
+The :mod:`test.support` module provides support for Python's regression
tests.
This module defines the following exceptions:
Set to the path that a temporary file may be created at. Any temporary that is
created should be closed and unlinked (removed).
-The :mod:`test.test_support` module defines the following functions:
+The :mod:`test.support` module defines the following functions:
.. function:: forget(module_name)
assert s.getvalue() == "hello"
-The :mod:`test.test_support` module defines the following classes:
+The :mod:`test.support` module defines the following classes:
.. class:: TransientResource(exc[, **kwargs])
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
#----------------------------------------------------------------------
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
DASH = b'-'
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
lexical_cmp = cmp
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
#----------------------------------------------------------------------
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
#----------------------------------------------------------------------
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
from bsddb.test.test_all import verbose
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
#----------------------------------------------------------------------
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
from bsddb.test.test_all import verbose
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
#----------------------------------------------------------------------
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
#----------------------------------------------------------------------
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
#----------------------------------------------------------------------
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
#----------------------------------------------------------------------
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
class DBSequenceTest(unittest.TestCase):
try:
from bsddb3 import test_support
except ImportError:
- from test import test_support
+ from test import support as test_support
#----------------------------------------------------------------------
import os
import shutil
import sys
-import test.test_support
+import test.support
import unittest
self.cleanup_testfn()
def cleanup_testfn(self):
- path = test.test_support.TESTFN
+ path = test.support.TESTFN
if os.path.isfile(path):
os.remove(path)
elif os.path.isdir(path):
shutil.rmtree(path)
- def write_setup(self, text, path=test.test_support.TESTFN):
+ def write_setup(self, text, path=test.support.TESTFN):
open(path, "w").write(text)
return path
cwd = os.getcwd()
# Create a directory and write the setup.py file there:
- os.mkdir(test.test_support.TESTFN)
- setup_py = os.path.join(test.test_support.TESTFN, "setup.py")
+ os.mkdir(test.support.TESTFN)
+ setup_py = os.path.join(test.support.TESTFN, "setup.py")
distutils.core.run_setup(
self.write_setup(setup_prints_cwd, path=setup_py))
import sys
import unittest
-from test.test_support import TESTFN
+from test.support import TESTFN
class test_dist(distutils.cmd.Command):
import os
import unittest
-from test.test_support import TESTFN
+from test.support import TESTFN
class SysconfigTestCase(unittest.TestCase):
from email import base64mime
from email import quoprimime
-from test.test_support import findfile, run_unittest
+from test.support import findfile, run_unittest
from email.test import __file__ as landmark
# email package unit tests for (optional) Asian codecs
import unittest
-from test.test_support import TestSkipped, run_unittest
+from test.support import TestSkipped, run_unittest
from email.test.test_email import TestEmailBase
from email.Charset import Charset
# email package unit tests for (optional) Asian codecs
import unittest
-from test.test_support import TestSkipped, run_unittest
+from test.support import TestSkipped, run_unittest
from email.test.test_email import TestEmailBase
from email.charset import Charset
from types import ListType
from email.test.test_email import TestEmailBase
-from test.test_support import TestSkipped
+from test.support import TestSkipped
import email
from email import __file__ as testfile
def test_main():
for testclass in _testclasses():
- test_support.run_unittest(testclass)
+ support.run_unittest(testclass)
\f
-from test.test_support import TestFailed
+from test.support import TestFailed
# A test for SF bug 422177: manifest float constants varied way too much in
# precision depending on whether Python was loading a module for the first
import sys
import os
-from test import test_support, seq_tests
+from test import support, seq_tests
def CmpToKey(mycmp):
'Convert a cmp= function into a key= function'
d.append(d)
d.append(400)
try:
- fo = open(test_support.TESTFN, "w")
+ fo = open(support.TESTFN, "w")
fo.write(str(d))
fo.close()
- fo = open(test_support.TESTFN, "r")
+ fo = open(support.TESTFN, "r")
self.assertEqual(fo.read(), repr(d))
finally:
fo.close()
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
def test_set_subscript(self):
a = self.type2test(range(20))
#
import unittest
-from test import test_support
+from test import support
#
# One test case for outstanding bugs at the moment:
self.normalized = b"AAA\nBBB\nCCC\nDDD\nEEE\n".decode("ASCII")
def tearDown(self):
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_issue1395_1(self):
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
TextIOWrapperTest)
if __name__ == "__main__":
import pickletools
import copyreg
-from test.test_support import TestFailed, TESTFN, run_with_locale
+from test.support import TestFailed, TESTFN, run_with_locale
from pickle import bytes_types
newsoft = min(hard, max(soft, 1024*2048))
resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard))
-from test import test_support
+from test import support
RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb',
'decimal', 'compiler', 'subprocess', 'urlfetch')
values that would normally be set by flags on the command line.
"""
- test_support.record_original_stdout(sys.stdout)
+ support.record_original_stdout(sys.stdout)
try:
opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsSrf:lu:t:TD:NLR:wM:n',
['help', 'verbose', 'quiet', 'exclude',
# stringobject.c filling slowly with random data
warm_char_cache()
elif o in ('-M', '--memlimit'):
- test_support.set_memlimit(a)
+ support.set_memlimit(a)
elif o in ('-u', '--use'):
u = [x.lower() for x in a.split(',')]
for r in u:
tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix],
trace=False, count=True)
test_times = []
- test_support.verbose = verbose # Tell tests to be moderately quiet
- test_support.use_resources = use_resources
+ support.verbose = verbose # Tell tests to be moderately quiet
+ support.use_resources = use_resources
save_modules = sys.modules.keys()
for test in tests:
if not quiet:
# Unload the newly imported modules (best effort finalization)
for module in sys.modules.keys():
if module not in save_modules and module.startswith("test."):
- test_support.unload(module)
+ support.unload(module)
# The lists won't be sorted if running with -r
good.sort()
print("Re-running test %r in verbose mode" % test)
sys.stdout.flush()
try:
- test_support.verbose = True
+ support.verbose = True
ok = runtest(test, generate, True, quiet, test_times, testdir,
huntrleaks, debug)
except KeyboardInterrupt:
]
NOTTESTS = {
- 'test_support',
'test_future1',
'test_future2',
}
def runtest_inner(test, generate, verbose, quiet, test_times,
testdir=None, huntrleaks=False, debug=False):
- test_support.unload(test)
+ support.unload(test)
if not testdir:
testdir = findtestdir()
if verbose:
test_times.append((test_time, test))
finally:
sys.stdout = save_stdout
- except test_support.ResourceDenied as msg:
+ except support.ResourceDenied as msg:
if not quiet:
print(test, "skipped --", msg)
sys.stdout.flush()
return -2
- except (ImportError, test_support.TestSkipped) as msg:
+ except (ImportError, support.TestSkipped) as msg:
if not quiet:
print(test, "skipped --", msg)
sys.stdout.flush()
return -1
except KeyboardInterrupt:
raise
- except test_support.TestFailed as msg:
+ except support.TestFailed as msg:
print("test", test, "failed --", msg)
sys.stdout.flush()
return 0
# since if a test leaves a file open, it cannot be deleted by name (while
# there's nothing we can do about that here either, we can display the
# name of the offending test, which is a real help).
- for name in (test_support.TESTFN,
+ for name in (support.TESTFN,
"db_home",
):
if not os.path.exists(name):
if __name__ == '__main__':
# Remove regrtest.py's own directory from the module search path. This
# prevents relative imports from working, and relative imports will screw
- # up the testing framework. E.g. if both test.test_support and
- # test_support are imported, they will not contain the same globals, and
+ # up the testing framework. E.g. if both test.support and
+ # support are imported, they will not contain the same globals, and
# much of the testing framework relies on the globals in the
- # test.test_support module.
+ # test.support module.
mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
i = pathlen = len(sys.path)
while i >= 0:
"""
import unittest, string, sys, struct
-from test import test_support
+from test import support
from collections import UserList
class Sequence:
"""Supporting definitions for the Python regression tests."""
-if __name__ != 'test.test_support':
- raise ImportError('test_support must be imported from the test package')
+if __name__ != 'test.support':
+ raise ImportError('support must be imported from the test package')
import contextlib
import errno
"""Run doctest on the given module. Return (#failures, #tests).
If optional argument verbosity is not specified (or is None), pass
- test_support's belief about verbosity on to doctest. Else doctest's
+ support's belief about verbosity on to doctest. Else doctest's
usual behavior is used (it searches sys.argv for -v).
"""
import os, unittest
from SimpleHTTPServer import SimpleHTTPRequestHandler
-from test import test_support
+from test import support
class SocketlessRequestHandler (SimpleHTTPRequestHandler):
def test_main():
- test_support.run_unittest(SimpleHTTPRequestHandlerTestCase)
+ support.run_unittest(SimpleHTTPRequestHandlerTestCase)
if __name__ == "__main__":
test_main()
import unittest
-from test.test_support import run_unittest, catch_warning
+from test.support import run_unittest, catch_warning
import sys
import warnings
#! /usr/bin/env python
import unittest
-from test import test_support
+from test import support
import __future__
GOOD_SERIALS = ("alpha", "beta", "candidate", "final")
".compiler_flag isn't int")
def test_main():
- test_support.run_unittest(FutureTest)
+ support.run_unittest(FutureTest)
if __name__ == "__main__":
test_main()
-from test.test_support import verbose, TestSkipped, run_unittest
+from test.support import verbose, TestSkipped, run_unittest
from _locale import (setlocale, LC_ALL, LC_CTYPE, LC_NUMERIC, RADIXCHAR, THOUSEP, nl_langinfo,
localeconv, Error)
import unittest
"""Unit tests for abc.py."""
import unittest
-from test import test_support
+from test import support
import abc
from inspect import isabstract
def test_main():
- test_support.run_unittest(TestABC)
+ support.run_unittest(TestABC)
if __name__ == "__main__":
import unittest
from numbers import Complex, Real, Rational, Integral
from numbers import Number
-from test import test_support
+from test import support
class TestNumbers(unittest.TestCase):
def test_int(self):
self.assertRaises(TypeError, int, c1)
def test_main():
- test_support.run_unittest(TestNumbers)
+ support.run_unittest(TestNumbers)
if __name__ == "__main__":
import unittest
import anydbm
import glob
-from test import test_support
+from test import support
-_fname = test_support.TESTFN
+_fname = support.TESTFN
_all_modules = []
def test_main():
try:
for module in dbm_iterator():
- test_support.run_unittest(AnyDBMTestCase)
+ support.run_unittest(AnyDBMTestCase)
finally:
delete_files()
"""
import unittest
-from test import test_support
+from test import support
from weakref import proxy
import array, io, math
from pickle import loads, dumps
def test_tofromfile(self):
a = array.array(self.typecode, 2*self.example)
self.assertRaises(TypeError, a.tofile)
- test_support.unlink(test_support.TESTFN)
- f = open(test_support.TESTFN, 'wb')
+ support.unlink(support.TESTFN)
+ f = open(support.TESTFN, 'wb')
try:
a.tofile(f)
f.close()
b = array.array(self.typecode)
- f = open(test_support.TESTFN, 'rb')
+ f = open(support.TESTFN, 'rb')
self.assertRaises(TypeError, b.fromfile)
b.fromfile(f, len(self.example))
self.assertEqual(b, array.array(self.typecode, self.example))
finally:
if not f.closed:
f.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_tofromlist(self):
a = array.array(self.typecode, 2*self.example)
def test_main(verbose=None):
import sys
- test_support.run_unittest(*tests)
+ support.run_unittest(*tests)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_unittest(*tests)
+ support.run_unittest(*tests)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
import sys, unittest
-from test import test_support
+from test import support
import _ast
def to_tuple(t):
self.assertEquals(to_tuple(ast2), to_tuple(ast))
def test_main():
- test_support.run_unittest(AST_Tests)
+ support.run_unittest(AST_Tests)
def main():
if __name__ != '__main__':
import asyncore, asynchat, socket, threading, time
import unittest
import sys
-from test import test_support
+from test import support
-HOST = test_support.HOST
+HOST = support.HOST
SERVER_QUIT = b'QUIT\n'
class echo_server(threading.Thread):
threading.Thread.__init__(self)
self.event = event
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.port = test_support.bind_port(self.sock)
+ self.port = support.bind_port(self.sock)
def run(self):
self.sock.listen(1)
def test_main(verbose=None):
- test_support.run_unittest(TestAsynchat, TestAsynchat_WithPoll,
+ support.run_unittest(TestAsynchat, TestAsynchat_WithPoll,
TestHelperFunctions, TestFifo)
if __name__ == "__main__":
import sys
import time
-from test import test_support
-from test.test_support import TESTFN, run_unittest, unlink
+from test import support
+from test.support import TESTFN, run_unittest, unlink
from io import BytesIO
from io import StringIO
-HOST = test_support.HOST
+HOST = support.HOST
class dummysocket:
def __init__(self):
self.evt = threading.Event()
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.settimeout(3)
- self.port = test_support.bind_port(self.sock)
+ self.port = support.bind_port(self.sock)
cap = BytesIO()
args = (self.evt, cap, self.sock)
import unittest
import io
import atexit
-from test import test_support
+from test import support
### helpers
def h1():
def test_main():
- test_support.run_unittest(TestCase)
+ support.run_unittest(TestCase)
if __name__ == "__main__":
test_main()
# Test audioop.
import audioop
-from test.test_support import verbose
+from test.support import verbose
def gendata1():
return b'\0\1\2'
# Augmented assignment test.
-from test.test_support import run_unittest
+from test.support import run_unittest
import unittest
import unittest
-from test import test_support
+from test import support
import base64
import binascii
\f
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == '__main__':
test_main()
-from test import test_support
-from test.test_support import bigaddrspacetest, MAX_Py_ssize_t
+from test import support
+from test.support import bigaddrspacetest, MAX_Py_ssize_t
import unittest
import operator
def test_main():
- test_support.run_unittest(StrTest)
+ support.run_unittest(StrTest)
if __name__ == '__main__':
if len(sys.argv) > 1:
- test_support.set_memlimit(sys.argv[1])
+ support.set_memlimit(sys.argv[1])
test_main()
-from test import test_support
-from test.test_support import bigmemtest, _1G, _2G
+from test import support
+from test.support import bigmemtest, _1G, _2G
import unittest
import operator
self.assertEquals(l[-10:], [5] * 10)
def test_main():
- test_support.run_unittest(StrTest, TupleTest, ListTest)
+ support.run_unittest(StrTest, TupleTest, ListTest)
if __name__ == '__main__':
if len(sys.argv) > 1:
- test_support.set_memlimit(sys.argv[1])
+ support.set_memlimit(sys.argv[1])
test_main()
"""Test the binascii C module."""
-from test import test_support
+from test import support
import unittest
import binascii
binascii.crc_hqx('', 0)
def test_main():
- test_support.run_unittest(BinASCIITest)
+ support.run_unittest(BinASCIITest)
if __name__ == "__main__":
test_main()
import binhex
import os
import unittest
-from test import test_support
+from test import support
class BinHexTestCase(unittest.TestCase):
def setUp(self):
- self.fname1 = test_support.TESTFN + "1"
- self.fname2 = test_support.TESTFN + "2"
+ self.fname1 = support.TESTFN + "1"
+ self.fname2 = support.TESTFN + "2"
def tearDown(self):
- test_support.unlink(self.fname1)
- test_support.unlink(self.fname2)
+ support.unlink(self.fname1)
+ support.unlink(self.fname2)
DATA = b'Jack is my hero'
def test_main():
- test_support.run_unittest(BinHexTestCase)
+ support.run_unittest(BinHexTestCase)
if __name__ == "__main__":
"""Tests for binary operators on subtypes of built-in types."""
import unittest
-from test import test_support
+from test import support
def gcd(a, b):
"""Greatest common divisor using Euclid's algorithm."""
"""
def test_main():
- test_support.run_unittest(RatTestCase)
+ support.run_unittest(RatTestCase)
if __name__ == "__main__":
import sys
import unittest
-from test import test_support
+from test import support
from collections import UserList
# We do a bit of trickery here to be able to test both the C implementation
TestInsortPython, TestInsortC,
TestErrorHandlingPython, TestErrorHandlingC]
- test_support.run_unittest(*test_classes)
- test_support.run_doctest(test_bisect, verbose)
+ support.run_unittest(*test_classes)
+ support.run_doctest(test_bisect, verbose)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
# Test properties of bool promised by PEP 285
import unittest
-from test import test_support
+from test import support
import os
def test_print(self):
try:
- fo = open(test_support.TESTFN, "w")
+ fo = open(support.TESTFN, "w")
print(False, True, file=fo)
fo.close()
- fo = open(test_support.TESTFN, "r")
+ fo = open(support.TESTFN, "r")
self.assertEqual(fo.read(), 'False True\n')
finally:
fo.close()
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
def test_repr(self):
self.assertEqual(repr(False), 'False')
def test_fileclosed(self):
try:
- f = open(test_support.TESTFN, "w")
+ f = open(support.TESTFN, "w")
self.assertIs(f.closed, False)
f.close()
self.assertIs(f.closed, True)
finally:
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
def test_operator(self):
import operator
self.assertEqual(str(e_bool), str(e_len))
def test_main():
- test_support.run_unittest(BoolTest)
+ support.run_unittest(BoolTest)
if __name__ == "__main__":
test_main()
import bsddb
import dbhash # Just so we know it's imported
import unittest
-from test import test_support
+from test import support
class TestBSDDB(unittest.TestCase):
openflag = 'c'
self.assertEqual(list(self.f), keys)
class TestBTree(TestBSDDB):
- fname = test_support.TESTFN
+ fname = support.TESTFN
openmethod = [bsddb.btopen]
class TestBTree_InMemory(TestBSDDB):
openmethod = [bsddb.btopen]
class TestHashTable(TestBSDDB):
- fname = test_support.TESTFN
+ fname = support.TESTFN
openmethod = [bsddb.hashopen]
class TestHashTable_InMemory(TestBSDDB):
## # Solaris Intel - rmasse 1/97
def test_main(verbose=None):
- test_support.run_unittest(
+ support.run_unittest(
TestBTree,
TestHashTable,
TestBTree_InMemory,
import tempfile
import time
import unittest
-from test.test_support import requires, verbose, run_unittest, unlink, rmtree
+from test.support import requires, verbose, run_unittest, unlink, rmtree
# When running as a script instead of within the regrtest framework, skip the
# requires test, since it's obvious we want to run them.
import unittest
-from test import test_support
+from test import support
# Simple test to ensure that optimizations in fileobject.c deliver
# the expected results. For best testing, run this under a debug-build
# .readline()s deliver what we wrote.
# Ensure we can open TESTFN for writing.
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
# Since C doesn't guarantee we can write/read arbitrary bytes in text
# files, use binary mode.
- f = open(test_support.TESTFN, "wb")
+ f = open(support.TESTFN, "wb")
try:
# write once with \n and once without
f.write(s)
f.write(b"\n")
f.write(s)
f.close()
- f = open(test_support.TESTFN, "rb")
+ f = open(support.TESTFN, "rb")
line = f.readline()
self.assertEqual(line, s + b"\n")
line = f.readline()
self.assert_(not line) # Must be at EOF
f.close()
finally:
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def drive_one(self, pattern):
for length in lengths:
self.drive_one(bytes(1000))
def test_main():
- test_support.run_unittest(BufferSizeTest)
+ support.run_unittest(BufferSizeTest)
if __name__ == "__main__":
test_main()
# Python test set -- built-in functions
-import test.test_support, unittest
-from test.test_support import fcmp, TESTFN, unlink, run_unittest, \
+import test.support, unittest
+from test.support import fcmp, TESTFN, unlink, run_unittest, \
run_with_locale
from operator import neg
import tempfile
import unittest
import warnings
-import test.test_support
+import test.support
import test.string_tests
import test.buffer_tests
def test_main():
- test.test_support.run_unittest(BytesTest)
- test.test_support.run_unittest(ByteArrayTest)
- test.test_support.run_unittest(AssortedBytesTest)
- test.test_support.run_unittest(BytesAsStringTest)
- test.test_support.run_unittest(ByteArrayAsStringTest)
- test.test_support.run_unittest(ByteArraySubclassTest)
- test.test_support.run_unittest(BytearrayPEP3137Test)
+ test.support.run_unittest(BytesTest)
+ test.support.run_unittest(ByteArrayTest)
+ test.support.run_unittest(AssortedBytesTest)
+ test.support.run_unittest(BytesAsStringTest)
+ test.support.run_unittest(ByteArrayAsStringTest)
+ test.support.run_unittest(ByteArraySubclassTest)
+ test.support.run_unittest(BytearrayPEP3137Test)
if __name__ == "__main__":
test_main()
#!/usr/bin/python
-from test import test_support
-from test.test_support import TESTFN
+from test import support
+from test.support import TESTFN
import unittest
from io import BytesIO
self.assertRaises(ValueError, bz2.decompress, self.DATA[:-10])
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
BZ2FileTest,
BZ2CompressorTest,
BZ2DecompressorTest,
FuncTest
)
- test_support.reap_children()
+ support.reap_children()
if __name__ == '__main__':
test_main()
def test_main():
- from test.test_support import TestSkipped
+ from test.support import TestSkipped
raise TestSkipped('test_cProfile test is current broken')
import calendar
import unittest
-from test import test_support
+from test import support
result_2004_text = """
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
OutputTestCase,
CalendarTestCase,
MondayTestCase,
import unittest
-from test import test_support
+from test import support
# The test cases here cover several paths through the function calling
# code. They depend on the METH_XXX flag that is used to define a C
def test_main():
- test_support.run_unittest(CFunctionCalls)
+ support.run_unittest(CFunctionCalls)
if __name__ == "__main__":
# these are all functions _testcapi exports whose name begins with 'test_'.
import sys
-from test import test_support
+from test import support
import _testcapi
def test_main():
for name in dir(_testcapi):
if name.startswith('test_'):
test = getattr(_testcapi, name)
- if test_support.verbose:
+ if support.verbose:
print("internal", name)
test()
# some extra thread-state tests driven via _testcapi
def TestThreadState():
- if test_support.verbose:
+ if support.verbose:
print("auto-thread-state")
idents = []
time.sleep(1)
# Check our main thread is in the list exactly 3 times.
if idents.count(thread.get_ident()) != 3:
- raise test_support.TestFailed(
+ raise support.TestFailed(
"Couldn't find main thread correctly in the list")
try:
import unittest
import collections
-from test import test_support
+from test import support
class SortedDict(collections.UserDict):
def items(self):
cf.set("sect", "option2", "splat")
def test_read_returns_file_list(self):
- file1 = test_support.findfile("cfgparser.1")
+ file1 = support.findfile("cfgparser.1")
# check when we pass a mix of readable and non-readable files:
cf = self.newconfig()
parsed_files = cf.read([file1, "nonexistant-file"])
"o4 = 1\n\n")
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
ConfigParserTestCase,
RawConfigParserTestCase,
SafeConfigParserTestCase,
-from test.test_support import run_unittest
+from test.support import run_unittest
import cgi
import os
import sys
"""#"
-import test.test_support, unittest
+import test.support, unittest
import codecs
self.assertRaises(UnicodeError, str, b'abc\001', codecname)
def test_main():
- test.test_support.run_unittest(CharmapCodecTest)
+ test.support.run_unittest(CharmapCodecTest)
if __name__ == "__main__":
test_main()
import unittest
-from test import test_support
+from test import support
testmeths = [
hash(a.f)
def test_main():
- test_support.run_unittest(ClassTests)
+ support.run_unittest(ClassTests)
if __name__=='__main__':
test_main()
-from test.test_support import run_unittest
+from test.support import run_unittest
from test.test_math import parse_testfile, test_file
import unittest
import os, sys
return True
def test_main(verbose=None):
- from test import test_support, test_cmd
- test_support.run_doctest(test_cmd, verbose)
+ from test import support, test_cmd
+ support.run_doctest(test_cmd, verbose)
def test_coverage(coverdir):
tracer=trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,],
# All tests are executed with environment variables ignored
# See test_cmd_line_script.py for testing of script execution
-import test.test_support, unittest
+import test.support, unittest
import sys
import subprocess
def test_main():
- test.test_support.run_unittest(CmdLineTest)
- test.test_support.reap_children()
+ test.support.run_unittest(CmdLineTest)
+ test.support.reap_children()
if __name__ == "__main__":
test_main()
import os
import os.path
import sys
-import test.test_support
+import test.support
import tempfile
import subprocess
import py_compile
import shutil
import zipfile
-verbose = test.test_support.verbose
+verbose = test.support.verbose
-# XXX ncoghlan: Should we consider moving these to test_support?
+# XXX ncoghlan: Should we consider moving these to support?
from test.test_cmd_line import _spawn_python, _kill_python
def _run_python(*args):
def test_main():
- test.test_support.run_unittest(CmdLineTest)
- test.test_support.reap_children()
+ test.support.run_unittest(CmdLineTest)
+ test.support.reap_children()
if __name__ == '__main__':
test_main()
print("consts:", tuple(consts(co.co_consts)))
def test_main(verbose=None):
- from test.test_support import run_doctest
+ from test.support import run_doctest
from test import test_code
run_doctest(test_code, verbose)
-import test.test_support, unittest
+import test.support, unittest
import sys, codecs, html.entities, unicodedata
class PosReturn:
self.assertRaises(TypeError, data.decode, encoding, "test.replacing")
def test_main():
- test.test_support.run_unittest(CodecCallbackTest)
+ test.support.run_unittest(CodecCallbackTest)
if __name__ == "__main__":
test_main()
# Codec encoding tests for PRC encodings.
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
has_iso10646 = True
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
# Codec encoding tests for HongKong encodings.
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
)
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
# Codec encoding tests for Japanese encodings.
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
)
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
# Codec encoding tests for ROK encodings.
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
)
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
# Codec encoding tests for ROC encodings.
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
)
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
# Codec mapping tests for PRC encodings
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
# Codec mapping tests for HongKong encodings
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
mapfileurl = 'http://people.freebsd.org/~perky/i18n/BIG5HKSCS-2004.TXT'
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
- test_support.use_resources = ['urlfetch']
+ support.use_resources = ['urlfetch']
test_main()
# Codec mapping tests for Japanese encodings
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
# Codec mapping tests for ROK encodings
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
pass_dectest = [(b'\\', '\u20a9')]
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
# Codec mapping tests for ROC encodings
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
]
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
-from test import test_support
+from test import support
import unittest
import codecs
import sys, _testcapi, io
try:
self.assertEquals(nameprep(orig), prepped)
except Exception as e:
- raise test_support.TestFailed("Test 3.%d: %s" % (pos+1, str(e)))
+ raise support.TestFailed("Test 3.%d: %s" % (pos+1, str(e)))
class IDNACodecTest(unittest.TestCase):
def test_builtin_decode(self):
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
UTF32Test,
UTF32LETest,
UTF32BETest,
Nick Mathewson
"""
import unittest
-from test.test_support import run_unittest, is_jython
+from test.support import run_unittest, is_jython
from codeop import compile_command, PyCF_DONT_IMPLY_DEDENT
import io
-import test.test_support, unittest
-from test.test_support import TESTFN, unlink
+import test.support, unittest
+from test.support import TESTFN, unlink
import os, sys
class CodingTest(unittest.TestCase):
sys.path.pop(0)
def test_main():
- test.test_support.run_unittest(CodingTest)
+ test.support.run_unittest(CodingTest)
if __name__ == "__main__":
test_main()
"""Unit tests for collections.py."""
import unittest, doctest
-from test import test_support
+from test import support
from collections import namedtuple
from collections import Hashable, Iterable, Iterator
from collections import Sized, Container, Callable
def test_main(verbose=None):
NamedTupleDocs = doctest.DocTestSuite(module=collections)
test_classes = [TestNamedTuple, NamedTupleDocs, TestOneTrickPonyABCs, TestCollectionABCs]
- test_support.run_unittest(*test_classes)
- test_support.run_doctest(collections, verbose)
+ support.run_unittest(*test_classes)
+ support.run_doctest(collections, verbose)
if __name__ == "__main__":
-import unittest, test.test_support
+import unittest, test.support
import colorsys
def frange(start, stop, step):
self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls))
def test_main():
- test.test_support.run_unittest(ColorsysTest)
+ test.support.run_unittest(ColorsysTest)
if __name__ == "__main__":
test_main()
import unittest
import os, tempfile, re
-from test.test_support import TestSkipped, run_unittest, reap_children
+from test.support import TestSkipped, run_unittest, reap_children
from commands import *
# The module says:
import unittest
-from test import test_support
+from test import support
class Empty:
def __repr__(self):
def test_main():
- test_support.run_unittest(ComparisonTest)
+ support.run_unittest(ComparisonTest)
if __name__ == '__main__':
test_main()
import unittest
import sys
import _ast
-from test import test_support
+from test import support
class TestSpecifics(unittest.TestCase):
def test_main():
- test_support.run_unittest(TestSpecifics)
+ support.run_unittest(TestSpecifics)
if __name__ == "__main__":
test_main()
import unittest, os
-from test import test_support
+from test import support
from random import random
from math import atan2
fo = None
try:
- fo = open(test_support.TESTFN, "w")
+ fo = open(support.TESTFN, "w")
print(a, b, file=fo)
fo.close()
- fo = open(test_support.TESTFN, "r")
+ fo = open(support.TESTFN, "r")
self.assertEqual(fo.read(), ("%s %s\n" % (a, b)))
finally:
if (fo is not None) and (not fo.closed):
fo.close()
try:
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
except (OSError, IOError):
pass
self.assertEquals(atan2(z2.imag, -1.), atan2(-0., -1.))
def test_main():
- test_support.run_unittest(ComplexTest)
+ support.run_unittest(ComplexTest)
if __name__ == "__main__":
test_main()
-from test.test_support import run_unittest
+from test.support import run_unittest
import unittest
import unittest
import threading
from contextlib import * # Tests __all__
-from test import test_support
+from test import support
class ContextManagerTestCase(unittest.TestCase):
# This is needed to make the test actually run under regrtest.py!
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
# Simple test suite for Cookie.py
-from test.test_support import run_unittest, run_doctest
+from test.support import run_unittest, run_doctest
import unittest
import Cookie
import re, os, time
from unittest import TestCase
-from test import test_support
+from test import support
class DateTimeTests(TestCase):
def test_lwp_valueless_cookie(self):
# cookies with no value should be saved and loaded consistently
from cookielib import LWPCookieJar
- filename = test_support.TESTFN
+ filename = support.TESTFN
c = LWPCookieJar()
interact_netscape(c, "http://www.acme.com/", 'boo')
self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None)
def test_bad_magic(self):
from cookielib import LWPCookieJar, MozillaCookieJar, LoadError
# IOErrors (eg. file doesn't exist) are allowed to propagate
- filename = test_support.TESTFN
+ filename = support.TESTFN
for cookiejar_class in LWPCookieJar, MozillaCookieJar:
c = cookiejar_class()
try:
# missing = sign in Cookie: header is regarded by Mozilla as a missing
# name, and by cookielib as a missing value
- filename = test_support.TESTFN
+ filename = support.TESTFN
c = MozillaCookieJar(filename)
interact_netscape(c, "http://www.acme.com/", 'eggs')
interact_netscape(c, "http://www.acme.com/", '"spam"; path=/foo/')
self.assertEquals(len(c), 6)
# save and restore
- filename = test_support.TESTFN
+ filename = support.TESTFN
try:
c.save(filename, ignore_discard=True)
year_plus_one = time.localtime()[0] + 1
- filename = test_support.TESTFN
+ filename = support.TESTFN
c = MozillaCookieJar(filename,
policy=DefaultCookiePolicy(rfc2965=True))
def test_main(verbose=None):
- test_support.run_unittest(
+ support.run_unittest(
DateTimeTests,
HeaderTests,
CookieTests,
import copyreg
import unittest
-from test import test_support
+from test import support
class TestCopy(unittest.TestCase):
def __reduce_ex__(self, proto):
return ""
def __reduce__(self):
- raise test_support.TestFailed("shouldn't call this")
+ raise support.TestFailed("shouldn't call this")
x = C()
y = copy.copy(x)
self.assert_(y is x)
def __reduce_ex__(self, proto):
return ""
def __reduce__(self):
- raise test_support.TestFailed("shouldn't call this")
+ raise support.TestFailed("shouldn't call this")
x = C()
y = copy.deepcopy(x)
self.assert_(y is x)
def global_foo(x, y): return x+y
def test_main():
- test_support.run_unittest(TestCopy)
+ support.run_unittest(TestCopy)
if __name__ == "__main__":
test_main()
import copyreg
import unittest
-from test import test_support
+from test import support
from test.pickletester import ExtensionSaver
class C:
def test_main():
- test_support.run_unittest(CopyRegTestCase)
+ support.run_unittest(CopyRegTestCase)
if __name__ == "__main__":
-from test import test_support
+from test import support
import unittest
import crypt
def test_crypt(self):
c = crypt.crypt('mypassword', 'ab')
- if test_support.verbose:
+ if support.verbose:
print('Test encryption: ', c)
def test_main():
- test_support.run_unittest(CryptTestCase)
+ support.run_unittest(CryptTestCase)
if __name__ == "__main__":
test_main()
from tempfile import TemporaryFile
import csv
import gc
-from test import test_support
+from test import support
class Test_Csv(unittest.TestCase):
"""
self.assertEqual(dialect.quotechar, "'")
if not hasattr(sys, "gettotalrefcount"):
- if test_support.verbose: print("*** skipping leakage tests ***")
+ if support.verbose: print("*** skipping leakage tests ***")
else:
class NUL:
def write(s, *args):
def test_main():
mod = sys.modules[__name__]
- test_support.run_unittest(
+ support.run_unittest(
*[getattr(mod, name) for name in dir(mod) if name.startswith('Test')]
)
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
import ctypes.test
def test_main():
# 'curses' resource be given on the regrtest command line using the -u
# option. If not available, nothing after this line will be executed.
-from test.test_support import requires, TestSkipped
+from test.support import requires, TestSkipped
requires('curses')
# XXX: if newterm was supported we could use it instead of initscr and not exit
import pickle
import unittest
-from test import test_support
+from test import support
from datetime import MINYEAR, MAXYEAR
from datetime import timedelta
self.assertEqual(datetime_sc, as_datetime)
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
-from test import test_support
+from test import support
import unittest
import os
import random
class DbmTestCase(unittest.TestCase):
def setUp(self):
- self.filename = test_support.TESTFN
+ self.filename = support.TESTFN
self.d = dbm.open(self.filename, 'c')
self.d.close()
def tearDown(self):
for suffix in ['', '.pag', '.dir', '.db']:
- test_support.unlink(self.filename + suffix)
+ support.unlink(self.filename + suffix)
def test_keys(self):
self.d = dbm.open(self.filename, 'c')
self.fail()
def test_main():
- test_support.run_unittest(DbmTestCase)
+ support.run_unittest(DbmTestCase)
if __name__ == '__main__':
test_main()
import pickle, copy
import unittest
from decimal import *
-from test.test_support import (TestSkipped, run_unittest, run_doctest,
+from test.support import (TestSkipped, run_unittest, run_doctest,
is_resource_enabled)
import random
try:
import unittest
-from test import test_support
+from test import support
def funcattrs(**kwds):
def decorate(func):
self.assertEqual(C.extra, 'second')
def test_main():
- test_support.run_unittest(TestDecorators)
- test_support.run_unittest(TestClassDecorators)
+ support.run_unittest(TestDecorators)
+ support.run_unittest(TestClassDecorators)
if __name__=="__main__":
test_main()
import copy
import tempfile
import unittest
-from test import test_support
+from test import support
from collections import defaultdict
def test_main():
- test_support.run_unittest(TestDefaultDict)
+ support.run_unittest(TestDefaultDict)
if __name__ == "__main__":
test_main()
from collections import deque
import unittest
-from test import test_support, seq_tests
+from test import support, seq_tests
from weakref import proxy
import copy
import pickle
self.assertEqual(list(d), [7, 8, 9])
d = deque(range(200), maxlen=10)
d.append(d)
- test_support.unlink(test_support.TESTFN)
- fo = open(test_support.TESTFN, "w")
+ support.unlink(support.TESTFN)
+ fo = open(support.TESTFN, "w")
try:
fo.write(str(d))
fo.close()
- fo = open(test_support.TESTFN, "r")
+ fo = open(support.TESTFN, "r")
self.assertEqual(fo.read(), repr(d))
finally:
fo.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
d = deque(range(10), maxlen=None)
self.assertEqual(repr(d), 'deque([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])')
- fo = open(test_support.TESTFN, "w")
+ fo = open(support.TESTFN, "w")
try:
fo.write(str(d))
fo.close()
- fo = open(test_support.TESTFN, "r")
+ fo = open(support.TESTFN, "r")
self.assertEqual(fo.read(), repr(d))
finally:
fo.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_comparisons(self):
d = deque('xabc'); d.popleft()
d = deque(range(200))
d.append(d)
try:
- test_support.unlink(test_support.TESTFN)
- fo = open(test_support.TESTFN, "w")
+ support.unlink(support.TESTFN)
+ fo = open(support.TESTFN, "w")
print(d, file=fo, end='')
fo.close()
- fo = open(test_support.TESTFN, "r")
+ fo = open(support.TESTFN, "r")
self.assertEqual(fo.read(), repr(d))
finally:
fo.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_init(self):
self.assertRaises(TypeError, deque, 'abc', 2, 3);
TestSubclassWithKwargs,
)
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
# doctests
from test import test_deque
- test_support.run_doctest(test_deque, verbose)
+ support.run_doctest(test_deque, verbose)
if __name__ == "__main__":
test_main(verbose=True)
import warnings
from copy import deepcopy
-from test import test_support
+from test import support
class OperatorsTest(unittest.TestCase):
## self.ateof = 1
## return s
##
- ## f = file(name=test_support.TESTFN, mode='w')
+ ## f = file(name=support.TESTFN, mode='w')
## lines = ['a\n', 'b\n', 'c\n']
## try:
## f.writelines(lines)
## f.close()
- ## f = CountedInput(test_support.TESTFN)
+ ## f = CountedInput(support.TESTFN)
## for (i, expected) in zip(range(1, 5) + [4], lines + 2 * [""]):
## got = f.readline()
## self.assertEqual(expected, got)
## f.close()
## except:
## pass
- ## test_support.unlink(test_support.TESTFN)
+ ## support.unlink(support.TESTFN)
def test_keywords(self):
# Testing keyword args to basic type constructors ...
def test_main():
# Run all local test cases, with PTypesLongInitTest first.
- test_support.run_unittest(PTypesLongInitTest, OperatorsTest,
+ support.run_unittest(PTypesLongInitTest, OperatorsTest,
ClassPropertiesAndMethods, DictProxyTests)
if __name__ == "__main__":
# of much interest anymore), and a few were fiddled to make the output
# deterministic.
-from test.test_support import sortdict
+from test.support import sortdict
import pprint
class defaultdict(dict):
# into the doctest examples, and unless the full test.test_descrtut
# business is used the name can change depending on how the test is
# invoked.
- from test import test_support, test_descrtut
- test_support.run_doctest(test_descrtut, verbose)
+ from test import support, test_descrtut
+ support.run_doctest(test_descrtut, verbose)
# This part isn't needed for regrtest, but for running the test directly.
if __name__ == "__main__":
import unittest
-from test import test_support
+from test import support
import sys, collections, random, string
type2test = Dict
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
DictTest,
GeneralMappingTests,
SubclassMappingTests,
def test_main(verbose=None):
import sys
- from test import test_support
+ from test import support
from test import test_dictcomps
- test_support.run_doctest(test_dictcomps, verbose)
+ support.run_doctest(test_dictcomps, verbose)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_doctest(test_dictcomps, verbose)
+ support.run_doctest(test_dictcomps, verbose)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
import unittest
-from test import test_support
+from test import support
class DictSetTest(unittest.TestCase):
self.assertEqual(len(values), 2)
def test_main():
- test_support.run_unittest(DictSetTest)
+ support.run_unittest(DictSetTest)
if __name__ == "__main__":
test_main()
import difflib
-from test.test_support import run_unittest, findfile
+from test.support import run_unittest, findfile
import unittest
import doctest
import sys
# Minimal tests for dis module
-from test.test_support import run_unittest
+from test.support import run_unittest
import unittest
import sys
import dis
"""
import distutils.tests
-import test.test_support
+import test.support
def test_main():
- test.test_support.run_unittest(distutils.tests.test_suite())
+ test.support.run_unittest(distutils.tests.test_suite())
if __name__ == "__main__":
Test script for doctest.
"""
-from test import test_support
+from test import support
import doctest
import warnings
def test_main():
# Check the doctest cases in doctest itself:
- test_support.run_doctest(doctest, verbosity=True)
+ support.run_doctest(doctest, verbosity=True)
# Check the doctest cases defined here:
from test import test_doctest
- test_support.run_doctest(test_doctest, verbosity=True)
+ support.run_doctest(test_doctest, verbosity=True)
import trace, sys, re, io
def test_coverage(coverdir):
"""
-from test import test_support
+from test import support
class C(object):
"""Class C.
def test_main():
from test import test_doctest2
EXPECTED = 19
- f, t = test_support.run_doctest(test_doctest2)
+ f, t = support.run_doctest(test_doctest2)
if t != EXPECTED:
- raise test_support.TestFailed("expected %d tests to run, not %d" %
+ raise support.TestFailed("expected %d tests to run, not %d" %
(EXPECTED, t))
# Pollute the namespace with a bunch of imported functions and classes,
from DocXMLRPCServer import DocXMLRPCServer
import httplib
-from test import test_support
+from test import support
import threading
import time
import unittest
response.read())
def test_main():
- test_support.run_unittest(DocXMLRPCHTTPGETServer)
+ support.run_unittest(DocXMLRPCHTTPGETServer)
if __name__ == '__main__':
test_main()
import os
import unittest
import dumbdbm
-from test import test_support
+from test import support
-_fname = test_support.TESTFN
+_fname = support.TESTFN
def _delete_files():
for ext in [".dir", ".dat", ".bak"]:
def test_main():
try:
- test_support.run_unittest(DumbDBMTestCase)
+ support.run_unittest(DumbDBMTestCase)
finally:
_delete_files()
import queue
import random
import unittest
-from test import test_support
+from test import support
DELAY = 0 # Set > 0 when testing a module other than dummy_thread, such as
# the 'thread' module.
self.lock.acquire()
start_time = int(time.time())
_thread.start_new_thread(delay_unlock,(self.lock, DELAY))
- if test_support.verbose:
+ if support.verbose:
print()
print("*** Waiting for thread to release the lock "\
"(approx. %s sec.) ***" % DELAY)
self.lock.acquire()
end_time = int(time.time())
- if test_support.verbose:
+ if support.verbose:
print("done")
self.failUnless((end_time - start_time) >= DELAY,
"Blocking by unconditional acquiring failed.")
thread_count = 5
testing_queue = queue.Queue(thread_count)
- if test_support.verbose:
+ if support.verbose:
print()
print("*** Testing multiple thread creation "\
"(will take approx. %s to %s sec.) ***" % (DELAY, thread_count))
_thread.start_new_thread(queue_mark,
(testing_queue, local_delay))
time.sleep(DELAY)
- if test_support.verbose:
+ if support.verbose:
print('done')
self.failUnless(testing_queue.qsize() == thread_count,
"Not all %s threads executed properly after %s sec." %
if imported_module:
_thread = imported_module
DELAY = 2
- if test_support.verbose:
+ if support.verbose:
print()
print("*** Using %s as _thread module ***" % _thread)
- test_support.run_unittest(LockTests, MiscTests, ThreadTests)
+ support.run_unittest(LockTests, MiscTests, ThreadTests)
if __name__ == '__main__':
test_main()
-from test import test_support
+from test import support
import unittest
import dummy_threading as _threading
import time
# module.
#delay = random.random() * 2
delay = 0
- if test_support.verbose:
+ if support.verbose:
print('task', self.getName(), 'will run for', delay, 'sec')
sema.acquire()
mutex.acquire()
running += 1
- if test_support.verbose:
+ if support.verbose:
print(running, 'tasks are running')
mutex.release()
time.sleep(delay)
- if test_support.verbose:
+ if support.verbose:
print('task', self.getName(), 'done')
mutex.acquire()
running -= 1
- if test_support.verbose:
+ if support.verbose:
print(self.getName(), 'is finished.', running, 'tasks are running')
mutex.release()
sema.release()
self.threads.append(t)
t.start()
- if test_support.verbose:
+ if support.verbose:
print('waiting for all tasks to complete')
for t in self.threads:
t.join()
- if test_support.verbose:
+ if support.verbose:
print('all tasks done')
def test_main():
- test_support.run_unittest(DummyThreadingTestCase)
+ support.run_unittest(DummyThreadingTestCase)
if __name__ == '__main__':
# The specific tests now live in Lib/email/test
from email.test.test_email import suite
-from test import test_support
+from test import support
def test_main():
- test_support.run_unittest(suite())
+ support.run_unittest(suite())
if __name__ == '__main__':
test_main()
import unittest
import sys
-from test import test_support
+from test import support
class G:
'Sequence using __getitem__'
def test_main(verbose=None):
testclasses = (EnumerateTestCase, SubclassTestCase, TestEmpty, TestBig,
TestReversed)
- test_support.run_unittest(*testclasses)
+ support.run_unittest(*testclasses)
# verify reference counting
import sys
if verbose and hasattr(sys, "gettotalrefcount"):
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_unittest(*testclasses)
+ support.run_unittest(*testclasses)
counts[i] = sys.gettotalrefcount()
print(counts)
"""test script for a few new invalid token catches"""
import unittest
-from test import test_support
+from test import support
class EOFTestCase(unittest.TestCase):
def test_EOFC(self):
except SyntaxError as msg:
self.assertEqual(str(msg), expect)
else:
- raise test_support.TestFailed
+ raise support.TestFailed
def test_EOFS(self):
expect = ("EOF while scanning triple-quoted string literal "
except SyntaxError as msg:
self.assertEqual(str(msg), expect)
else:
- raise test_support.TestFailed
+ raise support.TestFailed
def test_main():
- test_support.run_unittest(EOFTestCase)
+ support.run_unittest(EOFTestCase)
if __name__ == "__main__":
test_main()
import tempfile
import unittest
-from test import test_support
+from test import support
if not hasattr(select, "epoll"):
- raise test_support.TestSkipped("test works only on Linux 2.6")
+ raise support.TestSkipped("test works only on Linux 2.6")
try:
select.epoll()
except IOError as e:
if e.errno == errno.ENOSYS:
- raise test_support.TestSkipped("kernel doesn't support epoll()")
+ raise support.TestSkipped("kernel doesn't support epoll()")
class TestEPoll(unittest.TestCase):
ep.unregister(fd)
def test_main():
- test_support.run_unittest(TestEPoll)
+ support.run_unittest(TestEPoll)
if __name__ == "__main__":
test_main()
"""
import errno
-from test import test_support
+from test import support
import unittest
std_c_errors = frozenset(['EDOM', 'ERANGE'])
def test_main():
- test_support.run_unittest(ErrnoAttributeTests, ErrorcodeTests)
+ support.run_unittest(ErrnoAttributeTests, ErrorcodeTests)
if __name__ == '__main__':
-from test.test_support import run_unittest
+from test.support import run_unittest
import unittest
class ExceptionTestCase(unittest.TestCase):
import pickle
import weakref
-from test.test_support import TESTFN, unlink, run_unittest
+from test.support import TESTFN, unlink, run_unittest
# XXX This is not really enough, each *operation* should be tested!
... print(a, b)
>>> def f(*a, **k):
- ... print(a, test_support.sortdict(k))
+ ... print(a, support.sortdict(k))
>>> def g(x, *y, **z):
- ... print(x, y, test_support.sortdict(z))
+ ... print(x, y, support.sortdict(z))
>>> def h(j=1, a=2, h=3):
... print(j, a, h)
"""
-from test import test_support
+from test import support
def test_main():
from test import test_extcall # self import
- test_support.run_doctest(test_extcall, True)
+ support.run_doctest(test_extcall, True)
if __name__ == '__main__':
test_main()
import struct
import sys
import unittest
-from test.test_support import verbose, TESTFN, unlink, run_unittest
+from test.support import verbose, TESTFN, unlink, run_unittest
# TODO - Write tests for flock() and lockf().
from array import array
from weakref import proxy
-from test.test_support import TESTFN, findfile, run_unittest
+from test.support import TESTFN, findfile, run_unittest
from collections import UserList
class AutoFileTests(unittest.TestCase):
import os, filecmp, shutil, tempfile, shutil
import unittest
-from test import test_support
+from test import support
class FileCompareTestCase(unittest.TestCase):
def setUp(self):
- self.name = test_support.TESTFN
- self.name_same = test_support.TESTFN + '-same'
- self.name_diff = test_support.TESTFN + '-diff'
+ self.name = support.TESTFN
+ self.name_same = support.TESTFN + '-same'
+ self.name_diff = support.TESTFN + '-diff'
data = 'Contents of file go here.\n'
for name in [self.name, self.name_same, self.name_diff]:
output = open(name, 'w')
def test_main():
- test_support.run_unittest(FileCompareTestCase, DirCompareTestCase)
+ support.run_unittest(FileCompareTestCase, DirCompareTestCase)
if __name__ == "__main__":
test_main()
'''
import unittest
-from test.test_support import verbose, TESTFN, run_unittest
-from test.test_support import unlink as safe_unlink
+from test.support import verbose, TESTFN, run_unittest
+from test.support import unlink as safe_unlink
import sys, re
from io import StringIO
from fileinput import FileInput, hook_encoded
from array import array
from weakref import proxy
-from test.test_support import TESTFN, findfile, run_unittest
+from test.support import TESTFN, findfile, run_unittest
from collections import UserList
import _fileio
import unittest, struct
import os
-from test import test_support
+from test import support
import math
from math import isinf, isnan
import operator
# Implementation limitation in PyFloat_FromString()
self.assertRaises(ValueError, float, unicode("1"*10000))
- @test_support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE')
+ @support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE')
def test_float_with_comma(self):
# set locale to something that doesn't use '.' for the decimal point
# float must not accept the locale specific decimal point but
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
FormatFunctionsTestCase,
UnknownFormatTestCase,
IEEEFormatTestCase,
"""Test cases for the fnmatch module."""
-from test import test_support
+from test import support
import unittest
from fnmatch import fnmatch, fnmatchcase
def test_main():
- test_support.run_unittest(FnmatchTestCase)
+ support.run_unittest(FnmatchTestCase)
if __name__ == "__main__":
import os
import time
from test.fork_wait import ForkWait
-from test.test_support import TestSkipped, run_unittest, reap_children
+from test.support import TestSkipped, run_unittest, reap_children
try:
os.fork
-from test.test_support import verbose, TestFailed
+from test.support import verbose, TestFailed
import sys
-import test.test_support as test_support
+import test.support as support
import unittest
-maxsize = test_support.MAX_Py_ssize_t
+maxsize = support.MAX_Py_ssize_t
# test string formatting operator (I am not sure if this is being tested
# elsewhere but, surely, some of the given cases are *not* tested because
raise TestFailed('"%*d"%(maxsize, -127) should fail')
def test_main():
- test_support.run_unittest(FormatTest)
+ support.run_unittest(FormatTest)
if __name__ == "__main__":
"""Tests for Lib/fractions.py."""
from decimal import Decimal
-from test.test_support import run_unittest
+from test.support import run_unittest
import math
import operator
import fractions
# Test the frozen module defined in frozen.c.
-from test.test_support import captured_stdout, run_unittest
+from test.support import captured_stdout, run_unittest
import unittest
import sys, os
import time
from unittest import TestCase
-from test import test_support
+from test import support
-HOST = test_support.HOST
+HOST = support.HOST
# This function sets the evt 3 times:
# 1) when the connection is ready to be accepted.
self.evt = threading.Event()
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.settimeout(3)
- self.port = test_support.bind_port(self.sock)
+ self.port = support.bind_port(self.sock)
threading.Thread(target=server, args=(self.evt,self.sock)).start()
# Wait for the server to be ready.
self.evt.wait()
def test_main(verbose=None):
- test_support.run_unittest(GeneralTests)
+ support.run_unittest(GeneralTests)
if __name__ == '__main__':
test_main()
-from test import test_support
+from test import support
import types
import unittest
self.assertEqual(self.b.__doc__, None)
def test_main():
- test_support.run_unittest(FunctionPropertiesTest, ImplicitReferencesTest,
+ support.run_unittest(FunctionPropertiesTest, ImplicitReferencesTest,
ArbitraryFunctionAttrTest, FunctionDictsTest,
FunctionDocstringTest)
import functools
import unittest
-from test import test_support
+from test import support
from weakref import proxy
@staticmethod
TestWraps,
TestReduce
)
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
# Test various flavors of legal and illegal future statements
import unittest
-from test import test_support
+from test import support
import re
rx = re.compile('\((\S+).py, line (\d+)')
class FutureTest(unittest.TestCase):
def test_future1(self):
- test_support.unload('test_future1')
+ support.unload('test_future1')
from test import test_future1
self.assertEqual(test_future1.result, 6)
def test_future2(self):
- test_support.unload('test_future2')
+ support.unload('test_future2')
from test import test_future2
self.assertEqual(test_future2.result, 6)
def test_future3(self):
- test_support.unload('test_future3')
+ support.unload('test_future3')
from test import test_future3
def test_badfuture3(self):
def test_main():
- test_support.run_unittest(FutureTest)
+ support.run_unittest(FutureTest)
if __name__ == "__main__":
test_main()
from __future__ import division
import unittest
-from test import test_support
+from test import support
x = 2
def nester():
self.assertEqual(nester(), 3)
def test_main():
- test_support.run_unittest(TestFuture)
+ support.run_unittest(TestFuture)
if __name__ == "__main__":
test_main()
from __future__ import unicode_literals
import unittest
-from test import test_support
+from test import support
def test_main():
pass
import unittest
-from test.test_support import verbose, run_unittest
+from test.support import verbose, run_unittest
import sys
import gc
import weakref
import gdbm
import unittest
import os
-from test.test_support import verbose, TESTFN, run_unittest, unlink
+from test.support import verbose, TESTFN, run_unittest, unlink
filename = TESTFN
# Note that doctest and regrtest both look in sys.argv for a "-v" argument,
# so this works as expected in both ways of running regrtest.
def test_main(verbose=None):
- from test import test_support, test_generators
- test_support.run_doctest(test_generators, verbose)
+ from test import support, test_generators
+ support.run_doctest(test_generators, verbose)
# This part isn't needed for regrtest, but for running the test directly.
if __name__ == "__main__":
import unittest
-from test import test_support
+from test import support
import os
import genericpath
)
def test_getsize(self):
- f = open(test_support.TESTFN, "wb")
+ f = open(support.TESTFN, "wb")
try:
f.write(b"foo")
f.close()
- self.assertEqual(genericpath.getsize(test_support.TESTFN), 3)
+ self.assertEqual(genericpath.getsize(support.TESTFN), 3)
finally:
if not f.closed:
f.close()
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
def test_time(self):
- f = open(test_support.TESTFN, "wb")
+ f = open(support.TESTFN, "wb")
try:
f.write(b"foo")
f.close()
- f = open(test_support.TESTFN, "ab")
+ f = open(support.TESTFN, "ab")
f.write(b"bar")
f.close()
- f = open(test_support.TESTFN, "rb")
+ f = open(support.TESTFN, "rb")
d = f.read()
f.close()
self.assertEqual(d, b"foobar")
self.assert_(
- genericpath.getctime(test_support.TESTFN) <=
- genericpath.getmtime(test_support.TESTFN)
+ genericpath.getctime(support.TESTFN) <=
+ genericpath.getmtime(support.TESTFN)
)
finally:
if not f.closed:
f.close()
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
def test_exists(self):
- self.assertIs(genericpath.exists(test_support.TESTFN), False)
- f = open(test_support.TESTFN, "wb")
+ self.assertIs(genericpath.exists(support.TESTFN), False)
+ f = open(support.TESTFN, "wb")
try:
f.write(b"foo")
f.close()
- self.assertIs(genericpath.exists(test_support.TESTFN), True)
+ self.assertIs(genericpath.exists(support.TESTFN), True)
finally:
if not f.close():
f.close()
try:
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
except os.error:
pass
self.assertRaises(TypeError, genericpath.exists)
def test_isdir(self):
- self.assertIs(genericpath.isdir(test_support.TESTFN), False)
- f = open(test_support.TESTFN, "wb")
+ self.assertIs(genericpath.isdir(support.TESTFN), False)
+ f = open(support.TESTFN, "wb")
try:
f.write(b"foo")
f.close()
- self.assertIs(genericpath.isdir(test_support.TESTFN), False)
- os.remove(test_support.TESTFN)
- os.mkdir(test_support.TESTFN)
- self.assertIs(genericpath.isdir(test_support.TESTFN), True)
- os.rmdir(test_support.TESTFN)
+ self.assertIs(genericpath.isdir(support.TESTFN), False)
+ os.remove(support.TESTFN)
+ os.mkdir(support.TESTFN)
+ self.assertIs(genericpath.isdir(support.TESTFN), True)
+ os.rmdir(support.TESTFN)
finally:
if not f.close():
f.close()
try:
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
except os.error:
pass
try:
- os.rmdir(test_support.TESTFN)
+ os.rmdir(support.TESTFN)
except os.error:
pass
self.assertRaises(TypeError, genericpath.isdir)
def test_isfile(self):
- self.assertIs(genericpath.isfile(test_support.TESTFN), False)
- f = open(test_support.TESTFN, "wb")
+ self.assertIs(genericpath.isfile(support.TESTFN), False)
+ f = open(support.TESTFN, "wb")
try:
f.write(b"foo")
f.close()
- self.assertIs(genericpath.isfile(test_support.TESTFN), True)
- os.remove(test_support.TESTFN)
- os.mkdir(test_support.TESTFN)
- self.assertIs(genericpath.isfile(test_support.TESTFN), False)
- os.rmdir(test_support.TESTFN)
+ self.assertIs(genericpath.isfile(support.TESTFN), True)
+ os.remove(support.TESTFN)
+ os.mkdir(support.TESTFN)
+ self.assertIs(genericpath.isfile(support.TESTFN), False)
+ os.rmdir(support.TESTFN)
finally:
if not f.close():
f.close()
try:
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
except os.error:
pass
try:
- os.rmdir(test_support.TESTFN)
+ os.rmdir(support.TESTFN)
except os.error:
pass
self.assertRaises(TypeError, genericpath.isdir)
def test_samefile(self):
- f = open(test_support.TESTFN + "1", "wb")
+ f = open(support.TESTFN + "1", "wb")
try:
f.write(b"foo")
f.close()
self.assertIs(
genericpath.samefile(
- test_support.TESTFN + "1",
- test_support.TESTFN + "1"
+ support.TESTFN + "1",
+ support.TESTFN + "1"
),
True
)
# inode information and thus, that samefile() doesn't work
if hasattr(os, "symlink"):
os.symlink(
- test_support.TESTFN + "1",
- test_support.TESTFN + "2"
+ support.TESTFN + "1",
+ support.TESTFN + "2"
)
self.assertIs(
genericpath.samefile(
- test_support.TESTFN + "1",
- test_support.TESTFN + "2"
+ support.TESTFN + "1",
+ support.TESTFN + "2"
),
True
)
- os.remove(test_support.TESTFN + "2")
- f = open(test_support.TESTFN + "2", "wb")
+ os.remove(support.TESTFN + "2")
+ f = open(support.TESTFN + "2", "wb")
f.write(b"bar")
f.close()
self.assertIs(
genericpath.samefile(
- test_support.TESTFN + "1",
- test_support.TESTFN + "2"
+ support.TESTFN + "1",
+ support.TESTFN + "2"
),
False
)
if not f.close():
f.close()
try:
- os.remove(test_support.TESTFN + "1")
+ os.remove(support.TESTFN + "1")
except os.error:
pass
try:
- os.remove(test_support.TESTFN + "2")
+ os.remove(support.TESTFN + "2")
except os.error:
pass
self.assertRaises(TypeError, genericpath.samefile)
def test_main():
- test_support.run_unittest(AllCommonTest)
+ support.run_unittest(AllCommonTest)
if __name__=="__main__":
test_main()
def test_main(verbose=None):
import sys
- from test import test_support
+ from test import support
from test import test_genexps
- test_support.run_doctest(test_genexps, verbose)
+ support.run_doctest(test_genexps, verbose)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_doctest(test_genexps, verbose)
+ support.run_doctest(test_genexps, verbose)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
import unittest
-from test import test_support
+from test import support
from _testcapi import getargs_keywords
import warnings
pass # PY_LONG_LONG not available
else:
tests.append(LongLong_TestCase)
- test_support.run_unittest(*tests)
+ support.run_unittest(*tests)
if __name__ == "__main__":
test_main()
# test_getopt.py
# David Goodger <dgoodger@bigfoot.com> 2000-08-19
-from test.test_support import verbose, run_doctest, run_unittest
+from test.support import verbose, run_doctest, run_unittest
import unittest
import getopt
import gettext
import unittest
-from test import test_support
+from test import support
# TODO:
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == '__main__':
test_main()
import unittest
-from test.test_support import run_unittest, TESTFN
+from test.support import run_unittest, TESTFN
import glob
import os
import shutil
"""Verify that warnings are issued for global statements following use."""
-from test.test_support import run_unittest, check_syntax_error
+from test.support import run_unittest, check_syntax_error
import unittest
import warnings
# regression test, the filterwarnings() call has been added to
# regrtest.py.
-from test.test_support import run_unittest, check_syntax_error
+from test.support import run_unittest, check_syntax_error
import unittest
import sys
# testing import *
import grp
import unittest
-from test import test_support
+from test import support
class GroupDatabaseTestCase(unittest.TestCase):
self.assertRaises(KeyError, grp.getgrgid, fakegid)
def test_main():
- test_support.run_unittest(GroupDatabaseTestCase)
+ support.run_unittest(GroupDatabaseTestCase)
if __name__ == "__main__":
test_main()
"""
import unittest
-from test import test_support
+from test import support
import os
import gzip
class TestGzip(unittest.TestCase):
- filename = test_support.TESTFN
+ filename = support.TESTFN
def setUp (self):
- test_support.unlink(self.filename)
+ support.unlink(self.filename)
def tearDown (self):
- test_support.unlink(self.filename)
+ support.unlink(self.filename)
def test_write (self):
f.close()
def test_main(verbose=None):
- test_support.run_unittest(TestGzip)
+ support.run_unittest(TestGzip)
if __name__ == "__main__":
test_main(verbose=True)
#
import unittest
-from test import test_support
+from test import support
class HashEqualityTestCase(unittest.TestCase):
def test_main():
- test_support.run_unittest(HashEqualityTestCase)
+ support.run_unittest(HashEqualityTestCase)
if __name__ == "__main__":
import hashlib
import unittest
-from test import test_support
+from test import support
def hexstr(s):
def test_main():
- test_support.run_unittest(HashLibTestCase)
+ support.run_unittest(HashLibTestCase)
if __name__ == "__main__":
import random
import unittest
-from test import test_support
+from test import support
import sys
# We do a bit of trickery here to be able to test both the C implementation
from types import BuiltinFunctionType
test_classes = [TestHeapPython, TestHeapC, TestErrorHandling]
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
import hashlib
import unittest
import warnings
-from test import test_support
+from test import support
class TestVectorsTestCase(unittest.TestCase):
def digest(self):
return self._x.digest()
- with test_support.catch_warning():
+ with support.catch_warning():
warnings.simplefilter('error', RuntimeWarning)
try:
hmac.HMAC(b'a', b'b', digestmod=MockCrazyHash)
"Hexdigest of copy doesn't match original hexdigest.")
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
TestVectorsTestCase,
ConstructorTestCase,
SanityTestCase,
import htmllib
import unittest
-from test import test_support
+from test import support
class AnchorCollector(htmllib.HTMLParser):
])
def test_main():
- test_support.run_unittest(HTMLParserTestCase)
+ support.run_unittest(HTMLParserTestCase)
if __name__ == "__main__":
import HTMLParser
import pprint
import unittest
-from test import test_support
+from test import support
class EventCollector(HTMLParser.HTMLParser):
def test_main():
- test_support.run_unittest(HTMLParserTestCase)
+ support.run_unittest(HTMLParserTestCase)
if __name__ == "__main__":
from unittest import TestCase
-from test import test_support
+from test import support
-HOST = test_support.HOST
+HOST = support.HOST
class FakeSocket:
def __init__(self, text, fileclass=io.BytesIO):
def setUp(self):
self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- TimeoutTest.PORT = test_support.bind_port(self.serv)
+ TimeoutTest.PORT = support.bind_port(self.serv)
self.serv.listen(5)
def tearDown(self):
self.assertEqual(h.timeout, 30)
def test_main(verbose=None):
- test_support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest,
+ support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest,
HTTPSTimeoutTest)
if __name__ == '__main__':
import imaplib
import time
-from test import test_support
+from test import support
import unittest
def test_main():
- test_support.run_unittest(TestImaplib)
+ support.run_unittest(TestImaplib)
if __name__ == "__main__":
import imp
import unittest
-from test import test_support
+from test import support
class LockTests(unittest.TestCase):
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
LockTests,
ImportTests,
)
-from test.test_support import TESTFN, run_unittest, catch_warning
+from test.support import TESTFN, run_unittest, catch_warning
import unittest
import os
import py_compile
import warnings
import imp
-from test.test_support import unlink, TESTFN, unload
+from test.support import unlink, TESTFN, unload
def remove_files(name):
def test_import_name_binding(self):
# import x.y.z binds x in the current namespace
import test as x
- import test.test_support
+ import test.support
self.assert_(x is test, x.__name__)
- self.assert_(hasattr(test.test_support, "__file__"))
+ self.assert_(hasattr(test.support, "__file__"))
# import x.y.z as w binds z as w
- import test.test_support as y
- self.assert_(y is test.test_support, y.__name__)
+ import test.support as y
+ self.assert_(y is test.support, y.__name__)
def test_import_initless_directory_warning(self):
with catch_warning():
import imp
import os
import unittest
-from test import test_support
+from test import support
test_src = """\
pass
def test_main():
- test_support.run_unittest(ImportHooksTestCase)
+ support.run_unittest(ImportHooksTestCase)
if __name__ == "__main__":
test_main()
import unittest
-from test import test_support
+from test import support
import operator
-maxsize = test_support.MAX_Py_ssize_t
+maxsize = support.MAX_Py_ssize_t
minsize = -maxsize-1
class oldstyle:
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
BaseTestCase,
ListTestCase,
TupleTestCase,
import collections
from os.path import normcase
-from test.test_support import TESTFN, run_unittest
+from test.support import TESTFN, run_unittest
from test import inspect_fodder as mod
from test import inspect_fodder2 as mod2
import sys
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
L = [
('0', 0),
"""
import unittest
-from test import test_support
+from test import support
class TestHexOctBin(unittest.TestCase):
self.assertEqual(-0b1111111111111111111111111111111111111111111111111111111111111111, -18446744073709551615)
def test_main():
- test_support.run_unittest(TestHexOctBin)
+ support.run_unittest(TestHexOctBin)
if __name__ == "__main__":
test_main()
import array
import unittest
from itertools import chain
-from test import test_support
+from test import support
import codecs
import io # The module under test
class IOTest(unittest.TestCase):
def setUp(self):
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def tearDown(self):
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def write_ops(self, f):
self.assertEqual(f.write(b"blah."), 5)
self.assertEqual(f.read(2), b"x")
def test_raw_file_io(self):
- f = io.open(test_support.TESTFN, "wb", buffering=0)
+ f = io.open(support.TESTFN, "wb", buffering=0)
self.assertEqual(f.readable(), False)
self.assertEqual(f.writable(), True)
self.assertEqual(f.seekable(), True)
self.write_ops(f)
f.close()
- f = io.open(test_support.TESTFN, "rb", buffering=0)
+ f = io.open(support.TESTFN, "rb", buffering=0)
self.assertEqual(f.readable(), True)
self.assertEqual(f.writable(), False)
self.assertEqual(f.seekable(), True)
f.close()
def test_buffered_file_io(self):
- f = io.open(test_support.TESTFN, "wb")
+ f = io.open(support.TESTFN, "wb")
self.assertEqual(f.readable(), False)
self.assertEqual(f.writable(), True)
self.assertEqual(f.seekable(), True)
self.write_ops(f)
f.close()
- f = io.open(test_support.TESTFN, "rb")
+ f = io.open(support.TESTFN, "rb")
self.assertEqual(f.readable(), True)
self.assertEqual(f.writable(), False)
self.assertEqual(f.seekable(), True)
f.close()
def test_readline(self):
- f = io.open(test_support.TESTFN, "wb")
+ f = io.open(support.TESTFN, "wb")
f.write(b"abc\ndef\nxyzzy\nfoo")
f.close()
- f = io.open(test_support.TESTFN, "rb")
+ f = io.open(support.TESTFN, "rb")
self.assertEqual(f.readline(), b"abc\n")
self.assertEqual(f.readline(10), b"def\n")
self.assertEqual(f.readline(2), b"xy")
# a long time to build the >2GB file and takes >2GB of disk space
# therefore the resource must be enabled to run this test.
if sys.platform[:3] == 'win' or sys.platform == 'darwin':
- if not test_support.is_resource_enabled("largefile"):
+ if not support.is_resource_enabled("largefile"):
print("\nTesting large file ops skipped on %s." % sys.platform,
file=sys.stderr)
print("It requires %d bytes and a long time." % self.LARGE,
print("Use 'regrtest.py -u largefile test_io' to run it.",
file=sys.stderr)
return
- f = io.open(test_support.TESTFN, "w+b", 0)
+ f = io.open(support.TESTFN, "w+b", 0)
self.large_file_ops(f)
f.close()
- f = io.open(test_support.TESTFN, "w+b")
+ f = io.open(support.TESTFN, "w+b")
self.large_file_ops(f)
f.close()
def test_with_open(self):
for bufsize in (0, 1, 100):
f = None
- with open(test_support.TESTFN, "wb", bufsize) as f:
+ with open(support.TESTFN, "wb", bufsize) as f:
f.write(b"xxx")
self.assertEqual(f.closed, True)
f = None
try:
- with open(test_support.TESTFN, "wb", bufsize) as f:
+ with open(support.TESTFN, "wb", bufsize) as f:
1/0
except ZeroDivisionError:
self.assertEqual(f.closed, True)
def flush(self):
record.append(3)
io.FileIO.flush(self)
- f = MyFileIO(test_support.TESTFN, "w")
+ f = MyFileIO(support.TESTFN, "w")
f.write("xxx")
del f
self.assertEqual(record, [1, 2, 3])
def test_close_flushes(self):
- f = io.open(test_support.TESTFN, "wb")
+ f = io.open(support.TESTFN, "wb")
f.write(b"xxx")
f.close()
- f = io.open(test_support.TESTFN, "rb")
+ f = io.open(support.TESTFN, "rb")
self.assertEqual(f.read(), b"xxx")
f.close()
def test_array_writes(self):
a = array.array('i', range(10))
n = len(memoryview(a))
- f = io.open(test_support.TESTFN, "wb", 0)
+ f = io.open(support.TESTFN, "wb", 0)
self.assertEqual(f.write(a), n)
f.close()
- f = io.open(test_support.TESTFN, "wb")
+ f = io.open(support.TESTFN, "wb")
self.assertEqual(f.write(a), n)
f.close()
def test_closefd(self):
- self.assertRaises(ValueError, io.open, test_support.TESTFN, 'w',
+ self.assertRaises(ValueError, io.open, support.TESTFN, 'w',
closefd=False)
class MemorySeekTestMixin:
def setUp(self):
self.testdata = b"AAA\r\nBBB\rCCC\r\nDDD\nEEE\r\n"
self.normalized = b"AAA\nBBB\nCCC\nDDD\nEEE\n".decode("ascii")
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def tearDown(self):
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def testLineBuffering(self):
r = io.BytesIO()
def testBasicIO(self):
for chunksize in (1, 2, 3, 4, 5, 15, 16, 17, 31, 32, 33, 63, 64, 65):
for enc in "ascii", "latin1", "utf8" :# , "utf-16-be", "utf-16-le":
- f = io.open(test_support.TESTFN, "w+", encoding=enc)
+ f = io.open(support.TESTFN, "w+", encoding=enc)
f._CHUNK_SIZE = chunksize
self.assertEquals(f.write("abc"), 3)
f.close()
- f = io.open(test_support.TESTFN, "r+", encoding=enc)
+ f = io.open(support.TESTFN, "r+", encoding=enc)
f._CHUNK_SIZE = chunksize
self.assertEquals(f.tell(), 0)
self.assertEquals(f.read(), "abc")
self.assertEquals(rlines, wlines)
def testTelling(self):
- f = io.open(test_support.TESTFN, "w+", encoding="utf8")
+ f = io.open(support.TESTFN, "w+", encoding="utf8")
p0 = f.tell()
f.write("\xff\n")
p1 = f.tell()
u_suffix = "\u8888\n"
suffix = bytes(u_suffix.encode("utf-8"))
line = prefix + suffix
- f = io.open(test_support.TESTFN, "wb")
+ f = io.open(support.TESTFN, "wb")
f.write(line*2)
f.close()
- f = io.open(test_support.TESTFN, "r", encoding="utf-8")
+ f = io.open(support.TESTFN, "r", encoding="utf-8")
s = f.read(prefix_size)
self.assertEquals(s, str(prefix, "ascii"))
self.assertEquals(f.tell(), prefix_size)
def testSeekingToo(self):
# Regression test for a specific bug
data = b'\xe0\xbf\xbf\n'
- f = io.open(test_support.TESTFN, "wb")
+ f = io.open(support.TESTFN, "wb")
f.write(data)
f.close()
- f = io.open(test_support.TESTFN, "r", encoding="utf-8")
+ f = io.open(support.TESTFN, "r", encoding="utf-8")
f._CHUNK_SIZE # Just test that it exists
f._CHUNK_SIZE = 2
f.readline()
def testSeekAndTellWithData(data, min_pos=0):
"""Tell/seek to various points within a data stream and ensure
that the decoded data returned by read() is consistent."""
- f = io.open(test_support.TESTFN, 'wb')
+ f = io.open(support.TESTFN, 'wb')
f.write(data)
f.close()
- f = io.open(test_support.TESTFN, encoding='test_decoder')
+ f = io.open(support.TESTFN, encoding='test_decoder')
decoded = f.read()
f.close()
for i in range(min_pos, len(decoded) + 1): # seek positions
for j in [1, 5, len(decoded) - i]: # read lengths
- f = io.open(test_support.TESTFN, encoding='test_decoder')
+ f = io.open(support.TESTFN, encoding='test_decoder')
self.assertEquals(f.read(i), decoded[:i])
cookie = f.tell()
self.assertEquals(f.read(j), decoded[i:i + j])
nchars = len(line)
nbytes = len(line.encode(enc))
for chunk_size in (32, 64, 128, 256):
- f = io.open(test_support.TESTFN, "w+", encoding=enc)
+ f = io.open(support.TESTFN, "w+", encoding=enc)
f._CHUNK_SIZE = chunk_size
t0 = timer()
for i in range(nlines):
f.tell()
t4 = timer()
f.close()
- if test_support.verbose:
+ if support.verbose:
print("\nTiming test: %d lines of %d characters (%d bytes)" %
(nlines, nchars, nbytes))
print("File chunk size: %6s" % f._CHUNK_SIZE)
def test_main():
- test_support.run_unittest(IOTest, BytesIOTest, StringIOTest,
+ support.run_unittest(IOTest, BytesIOTest, StringIOTest,
BufferedReaderTest, BufferedWriterTest,
BufferedRWPairTest, BufferedRandomTest,
StatefulIncrementalDecoderTest,
import unittest
-from test.test_support import TestSkipped, run_unittest
+from test.support import TestSkipped, run_unittest
import os, struct
try:
import fcntl, termios
# testing of error conditions uncovered when using extension types.
import unittest
-from test import test_support
+from test import support
import sys
\f
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
TestIsInstanceExceptions,
TestIsSubclassExceptions,
TestIsInstanceIsSubclass
# Test iterators.
import unittest
-from test.test_support import run_unittest, TESTFN, unlink
+from test.support import run_unittest, TESTFN, unlink
# Test result of triple loop (too big to inline)
TRIPLETS = [(0, 0, 0), (0, 0, 1), (0, 0, 2),
"""
import unittest
-from test import test_support
+from test import support
from itertools import repeat
from collections import deque
from builtins import len as _len
TestList,
TestListReversed,
]
- test_support.run_unittest(*unittests)
+ support.run_unittest(*unittests)
if __name__ == "__main__":
test_main()
import unittest
-from test import test_support
+from test import support
from itertools import *
from weakref import proxy
import sys
import operator
import random
from functools import reduce
-maxsize = test_support.MAX_Py_ssize_t
+maxsize = support.MAX_Py_ssize_t
minsize = -maxsize-1
def lzip(*args):
test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC,
RegressionTests, LengthTransparency,
SubclassWithKwargsTest, TestExamples)
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
# doctest the examples in the library reference
- test_support.run_doctest(sys.modules[__name__], verbose)
+ support.run_doctest(sys.modules[__name__], verbose)
if __name__ == "__main__":
test_main(verbose=True)
"""
import json.tests
-import test.test_support
+import test.support
def test_main():
- test.test_support.run_unittest(json.tests.test_suite())
- test.test_support.run_doctest(json)
+ test.support.run_unittest(json.tests.test_suite())
+ test.support.run_doctest(json)
if __name__ == "__main__":
__email__ = "seojiwon at gmail dot com"
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
def posonly_sum(pos_arg1, *arg, **kwarg):
return pos_arg1 + sum(arg) + sum(kwarg.values())
import sys
import unittest
-from test import test_support
+from test import support
if not hasattr(select, "kqueue"):
- raise test_support.TestSkipped("test works only on BSD")
+ raise support.TestSkipped("test works only on BSD")
class TestKQueue(unittest.TestCase):
def test_create_queue(self):
serverSocket.close()
def test_main():
- test_support.run_unittest(TestKQueue)
+ support.run_unittest(TestKQueue)
if __name__ == "__main__":
test_main()
import stat
import sys
import unittest
-from test.test_support import run_unittest, TESTFN, verbose, requires, \
+from test.support import run_unittest, TESTFN, verbose, requires, \
TestSkipped, unlink
try:
# because of running
from lib2to3.tests import test_fixers, test_pytree, test_util
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
def suite():
tests = unittest.TestSuite()
import sys
-from test import test_support, list_tests
+from test import support, list_tests
class ListTest(list_tests.CommonTest):
type2test = list
self.assertRaises((MemoryError, OverflowError), imul, lst, n)
def test_main(verbose=None):
- test_support.run_unittest(ListTest)
+ support.run_unittest(ListTest)
# verify reference counting
import sys
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_unittest(ListTest)
+ support.run_unittest(ListTest)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
def test_main(verbose=None):
import sys
- from test import test_support
+ from test import support
from test import test_listcomps
- test_support.run_doctest(test_listcomps, verbose)
+ support.run_doctest(test_listcomps, verbose)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_doctest(test_genexps, verbose)
+ support.run_doctest(test_genexps, verbose)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
def test_main(verbose=None):
import sys
- from test import test_support
+ from test import support
from test import test_listcomps
- test_support.run_doctest(test_listcomps, verbose)
+ support.run_doctest(test_listcomps, verbose)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_doctest(test_genexps, verbose)
+ support.run_doctest(test_genexps, verbose)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
def test_main(verbose=None):
import sys
- from test import test_support
+ from test import support
from test import test_listcomps
- test_support.run_doctest(test_listcomps, verbose)
+ support.run_doctest(test_listcomps, verbose)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_doctest(test_listcomps, verbose)
+ support.run_doctest(test_listcomps, verbose)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
-from test.test_support import verbose, TestSkipped
+from test.support import verbose, TestSkipped
import locale
import sys
import struct
import sys
import tempfile
-from test.test_support import captured_stdout, run_with_locale, run_unittest
+from test.support import captured_stdout, run_with_locale, run_unittest
import textwrap
import threading
import time
import unittest
-from test import test_support
+from test import support
import sys
import random
self.assertRaises(OverflowError, int, float('nan'))
def test_main():
- test_support.run_unittest(LongTest)
+ support.run_unittest(LongTest)
if __name__ == "__main__":
test_main()
# trick just part of test_long into using future division.
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
class TrueDivisionTests(unittest.TestCase):
def test(self):
import unittest
-from test import test_support
+from test import support
class LongExpText(unittest.TestCase):
def test_longexp(self):
self.assertEqual(len(l), REPS)
def test_main():
- test_support.run_unittest(LongExpText)
+ support.run_unittest(LongExpText)
if __name__=="__main__":
test_main()
import macpath
-from test import test_support
+from test import support
import unittest
def test_main():
- test_support.run_unittest(MacPathTestCase)
+ support.run_unittest(MacPathTestCase)
if __name__ == "__main__":
import email.message
import re
import io
-from test import test_support
+from test import support
import unittest
import mailbox
import glob
_template = 'From: foo\n\n%s'
def setUp(self):
- self._path = test_support.TESTFN
+ self._path = support.TESTFN
self._delete_recursively(self._path)
self._box = self._factory(self._path)
self._box.close()
self._delete_recursively(self._path)
for lock_remnant in glob.glob(self._path + '.*'):
- test_support.unlink(lock_remnant)
+ support.unlink(lock_remnant)
def test_add_from_string(self):
# Add a string starting with 'From ' to the mailbox
self._box.close()
self._delete_recursively(self._path)
for lock_remnant in glob.glob(self._path + '.*'):
- test_support.unlink(lock_remnant)
+ support.unlink(lock_remnant)
def test_labels(self):
# Get labels from the mailbox
_factory = mailbox.Message # Overridden by subclasses to reuse tests
def setUp(self):
- self._path = test_support.TESTFN
+ self._path = support.TESTFN
def tearDown(self):
self._delete_recursively(self._path)
class TestProxyFile(TestProxyFileBase):
def setUp(self):
- self._path = test_support.TESTFN
+ self._path = support.TESTFN
self._file = open(self._path, 'wb+')
def tearDown(self):
class TestPartialFile(TestProxyFileBase):
def setUp(self):
- self._path = test_support.TESTFN
+ self._path = support.TESTFN
self._file = open(self._path, 'wb+')
def tearDown(self):
def setUp(self):
# create a new maildir mailbox to work with:
- self._dir = test_support.TESTFN
+ self._dir = support.TESTFN
os.mkdir(self._dir)
os.mkdir(os.path.join(self._dir, "cur"))
os.mkdir(os.path.join(self._dir, "tmp"))
"""Test an empty maildir mailbox"""
# Test for regression on bug #117490:
# Make sure the boxes attribute actually gets set.
- self.mbox = mailbox.Maildir(test_support.TESTFN)
+ self.mbox = mailbox.Maildir(support.TESTFN)
#self.assert_(hasattr(self.mbox, "boxes"))
#self.assertEqual(len(self.mbox.boxes), 0)
self.assert_(self.mbox.next() is None)
def test_nonempty_maildir_cur(self):
self.createMessage("cur")
- self.mbox = mailbox.Maildir(test_support.TESTFN)
+ self.mbox = mailbox.Maildir(support.TESTFN)
#self.assertEqual(len(self.mbox.boxes), 1)
self.assert_(self.mbox.next() is not None)
self.assert_(self.mbox.next() is None)
def test_nonempty_maildir_new(self):
self.createMessage("new")
- self.mbox = mailbox.Maildir(test_support.TESTFN)
+ self.mbox = mailbox.Maildir(support.TESTFN)
#self.assertEqual(len(self.mbox.boxes), 1)
self.assert_(self.mbox.next() is not None)
self.assert_(self.mbox.next() is None)
def test_nonempty_maildir_both(self):
self.createMessage("cur")
self.createMessage("new")
- self.mbox = mailbox.Maildir(test_support.TESTFN)
+ self.mbox = mailbox.Maildir(support.TESTFN)
#self.assertEqual(len(self.mbox.boxes), 2)
self.assert_(self.mbox.next() is not None)
self.assert_(self.mbox.next() is not None)
TestMHMessage, TestBabylMessage, TestMMDFMessage,
TestMessageConversion, TestProxyFile, TestPartialFile,
MaildirTestCase)
- test_support.run_unittest(*tests)
- test_support.reap_children()
+ support.run_unittest(*tests)
+ support.reap_children()
if __name__ == '__main__':
#!/usr/bin/env python
-from test import test_support
+from test import support
import marshal
import sys
import unittest
new = marshal.loads(marshal.dumps(sample, *extra))
self.assertEqual(sample, new)
try:
- f = open(test_support.TESTFN, "wb")
+ f = open(support.TESTFN, "wb")
try:
marshal.dump(sample, f, *extra)
finally:
f.close()
- f = open(test_support.TESTFN, "rb")
+ f = open(support.TESTFN, "rb")
try:
new = marshal.load(f)
finally:
f.close()
self.assertEqual(sample, new)
finally:
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
class IntTestCase(unittest.TestCase, HelperMixin):
def test_ints(self):
def test_main():
- test_support.run_unittest(IntTestCase,
+ support.run_unittest(IntTestCase,
FloatTestCase,
StringTestCase,
CodeTestCase,
# Python test set -- math module
# XXXX Should not do tests around zero only
-from test.test_support import run_unittest, verbose
+from test.support import run_unittest, verbose
import unittest
import math
import os
"""
import unittest
-from test import test_support
+from test import support
import io
import sys
tests = [PyBytesIOTest, PyStringIOTest]
if has_c_implementation:
tests.extend([CBytesIOTest])
- test_support.run_unittest(*tests)
+ support.run_unittest(*tests)
if __name__ == '__main__':
test_main()
"""
import unittest
-import test.test_support
+import test.support
class MemoryviewTest(unittest.TestCase):
self.assertRaises(TypeError, memoryview, ob, argument=True)
def test_main():
- test.test_support.run_unittest(MemoryviewTest)
+ test.support.run_unittest(MemoryviewTest)
if __name__ == "__main__":
__test__ = {'doctests' : doctests}
def test_main(verbose=False):
- from test import test_support
+ from test import support
from test import test_metaclass
- test_support.run_doctest(test_metaclass, verbose)
+ support.run_doctest(test_metaclass, verbose)
if __name__ == "__main__":
test_main(verbose=True)
import unittest
-from test import test_support
+from test import support
import string, mimetools
import io
self.assertEqual(msg.getencoding(), "8bit")
def test_main():
- test_support.run_unittest(MimeToolsTest)
+ support.run_unittest(MimeToolsTest)
if __name__=="__main__":
test_main()
import io
import unittest
-from test import test_support
+from test import support
# Tell it we don't know about external files:
mimetypes.knownfiles = []
def test_main():
- test_support.run_unittest(MimeTypesTestCase)
+ support.run_unittest(MimeTypesTestCase)
if __name__ == "__main__":
import sys
import pickle
from io import StringIO
-from test.test_support import verbose, run_unittest, TestSkipped
+from test.support import verbose, run_unittest, TestSkipped
import unittest
import xml.dom
-from test.test_support import TESTFN, run_unittest
+from test.support import TESTFN, run_unittest
import mmap
import unittest
import os, re
# Test the module type
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
import sys
ModuleType = type(sys)
import distutils.dir_util
import tempfile
-from test import test_support
+from test import support
try: set
except NameError: from sets import Set as set
def test_main():
distutils.log.set_threshold(distutils.log.WARN)
- test_support.run_unittest(ModuleFinderTest)
+ support.run_unittest(ModuleFinderTest)
if __name__ == "__main__":
unittest.main()
# Unit test for multibytecodec itself
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
-from test.test_support import TESTFN
+from test.support import TESTFN
import unittest, io, codecs, sys, os
ALL_CJKENCODINGS = [
print('# coding:', enc, file=io.open(TESTFN, 'w'))
exec(open(TESTFN).read())
finally:
- test_support.unlink(TESTFN)
+ support.unlink(TESTFN)
class Test_IncrementalEncoder(unittest.TestCase):
finally:
f.close()
finally:
- test_support.unlink(TESTFN)
+ support.unlink(TESTFN)
class Test_StreamWriter(unittest.TestCase):
if len('\U00012345') == 2: # UCS2
myunichr(x).encode('iso_2022_jp', 'ignore')
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
import sys, codecs
import unittest, re
-from test import test_support
+from test import support
from io import BytesIO
class TestBase:
try:
self.open_mapping_file() # test it to report the error early
except IOError:
- raise test_support.TestSkipped("Could not retrieve "+self.mapfileurl)
+ raise support.TestSkipped("Could not retrieve "+self.mapfileurl)
def open_mapping_file(self):
- return test_support.open_urlresource(self.mapfileurl)
+ return support.open_urlresource(self.mapfileurl)
def test_mapping_file(self):
if self.mapfileurl.endswith('.xml'):
-from test.test_support import verbose, TESTFN
+from test.support import verbose, TESTFN
import random
import os
import netrc, os, unittest, sys
-from test import test_support
+from test import support
TEST_NETRC = """
machine foo login log1 password pass1 account acct1
"""
-temp_filename = test_support.TESTFN
+temp_filename = support.TESTFN
class NetrcTestCase(unittest.TestCase):
self.assert_(nrc.hosts['default'] == ('log2', None, 'pass2'))
def test_main():
- test_support.run_unittest(NetrcTestCase)
+ support.run_unittest(NetrcTestCase)
if __name__ == "__main__":
test_main()
-from test import test_support
+from test import support
import unittest
import nis
maps = nis.maps()
except nis.error as msg:
# NIS is probably not active, so this test isn't useful
- if test_support.verbose:
+ if support.verbose:
print("Test Skipped:", msg)
# Can't raise TestSkipped as regrtest only recognizes the exception
# import time.
break
def test_main():
- test_support.run_unittest(NisTests)
+ support.run_unittest(NisTests)
if __name__ == '__main__':
test_main()
-from test.test_support import run_unittest, open_urlresource
+from test.support import run_unittest, open_urlresource
import unittest
import sys
import ntpath
import os
-from test.test_support import verbose, TestFailed
-import test.test_support as test_support
+from test.support import verbose, TestFailed
+import test.support as support
import unittest
def test_main():
- test_support.run_unittest(TestNtpath)
+ support.run_unittest(TestNtpath)
if __name__ == "__main__":
# Python test set -- part 2, opcodes
-from test.test_support import run_unittest
+from test.support import run_unittest
import unittest
class OpcodeTest(unittest.TestCase):
# Test to see if openpty works. (But don't worry if it isn't available.)
import os, unittest
-from test.test_support import run_unittest, TestSkipped
+from test.support import run_unittest, TestSkipped
if not hasattr(os, "openpty"):
raise TestSkipped("No openpty() available.")
import operator
import unittest
-from test import test_support
+from test import support
class Seq1:
def __init__(self, lst):
OperatorTestCase,
)
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
import unittest
from io import StringIO
-from test import test_support
+from test import support
from optparse import make_option, Option, IndentedHelpFormatter, \
self.parser.add_option("-f", "--file", type="file", dest="file")
def tearDown(self):
- if os.path.isdir(test_support.TESTFN):
- os.rmdir(test_support.TESTFN)
- elif os.path.isfile(test_support.TESTFN):
- os.unlink(test_support.TESTFN)
+ if os.path.isdir(support.TESTFN):
+ os.rmdir(support.TESTFN)
+ elif os.path.isfile(support.TESTFN):
+ os.unlink(support.TESTFN)
class MyOption (Option):
def check_file(option, opt, value):
TYPE_CHECKER["file"] = check_file
def test_filetype_ok(self):
- open(test_support.TESTFN, "w").close()
- self.assertParseOK(["--file", test_support.TESTFN, "-afoo"],
- {'file': test_support.TESTFN, 'a': 'foo'},
+ open(support.TESTFN, "w").close()
+ self.assertParseOK(["--file", support.TESTFN, "-afoo"],
+ {'file': support.TESTFN, 'a': 'foo'},
[])
def test_filetype_noexist(self):
- self.assertParseFail(["--file", test_support.TESTFN, "-afoo"],
+ self.assertParseFail(["--file", support.TESTFN, "-afoo"],
"%s: file does not exist" %
- test_support.TESTFN)
+ support.TESTFN)
def test_filetype_notfile(self):
- os.mkdir(test_support.TESTFN)
- self.assertParseFail(["--file", test_support.TESTFN, "-afoo"],
+ os.mkdir(support.TESTFN)
+ self.assertParseFail(["--file", support.TESTFN, "-afoo"],
"%s: not a regular file" %
- test_support.TESTFN)
+ support.TESTFN)
class TestExtendAddActions(BaseTest):
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == '__main__':
test_main()
import unittest
import warnings
import sys
-from test import test_support
+from test import support
# Tests creating TESTFN
class FileTests(unittest.TestCase):
def setUp(self):
- if os.path.exists(test_support.TESTFN):
- os.unlink(test_support.TESTFN)
+ if os.path.exists(support.TESTFN):
+ os.unlink(support.TESTFN)
tearDown = setUp
def test_access(self):
- f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR)
+ f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
os.close(f)
- self.assert_(os.access(test_support.TESTFN, os.W_OK))
+ self.assert_(os.access(support.TESTFN, os.W_OK))
def test_closerange(self):
- f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR)
+ f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
# close a fd that is open, and one that isn't
os.closerange(f, f+2)
self.assertRaises(OSError, os.write, f, "a")
class TemporaryFileTests(unittest.TestCase):
def setUp(self):
self.files = []
- os.mkdir(test_support.TESTFN)
+ os.mkdir(support.TESTFN)
def tearDown(self):
for name in self.files:
os.unlink(name)
- os.rmdir(test_support.TESTFN)
+ os.rmdir(support.TESTFN)
def check_tempfile(self, name):
# make sure it doesn't already exist:
r"test_os$")
self.check_tempfile(os.tempnam())
- name = os.tempnam(test_support.TESTFN)
+ name = os.tempnam(support.TESTFN)
self.check_tempfile(name)
- name = os.tempnam(test_support.TESTFN, "pfx")
+ name = os.tempnam(support.TESTFN, "pfx")
self.assert_(os.path.basename(name)[:3] == "pfx")
self.check_tempfile(name)
# Test attributes on return values from os.*stat* family.
class StatAttributeTests(unittest.TestCase):
def setUp(self):
- os.mkdir(test_support.TESTFN)
- self.fname = os.path.join(test_support.TESTFN, "f1")
+ os.mkdir(support.TESTFN)
+ self.fname = os.path.join(support.TESTFN, "f1")
f = open(self.fname, 'wb')
f.write(b"ABC")
f.close()
def tearDown(self):
os.unlink(self.fname)
- os.rmdir(test_support.TESTFN)
+ os.rmdir(support.TESTFN)
def test_stat_attributes(self):
if not hasattr(os, "stat"):
def test_utime_dir(self):
delta = 1000000
- st = os.stat(test_support.TESTFN)
+ st = os.stat(support.TESTFN)
# round to int, because some systems may support sub-second
# time stamps in stat, but not in utime.
- os.utime(test_support.TESTFN, (st.st_atime, int(st.st_mtime-delta)))
- st2 = os.stat(test_support.TESTFN)
+ os.utime(support.TESTFN, (st.st_atime, int(st.st_mtime-delta)))
+ st2 = os.stat(support.TESTFN)
self.assertEquals(st2.st_mtime, int(st.st_mtime-delta))
# Restrict test to Win32, since there is no guarantee other
if kernel32.GetVolumeInformationA(root, None, 0, None, None, None, buf, len(buf)):
return buf.value
- if get_file_system(test_support.TESTFN) == "NTFS":
+ if get_file_system(support.TESTFN) == "NTFS":
def test_1565150(self):
t1 = 1159195039.25
os.utime(self.fname, (t1, t1))
# link/ a symlink to TESTFN.2
# TEST2/
# tmp4 a lone file
- walk_path = join(test_support.TESTFN, "TEST1")
+ walk_path = join(support.TESTFN, "TEST1")
sub1_path = join(walk_path, "SUB1")
sub11_path = join(sub1_path, "SUB11")
sub2_path = join(walk_path, "SUB2")
tmp2_path = join(sub1_path, "tmp2")
tmp3_path = join(sub2_path, "tmp3")
link_path = join(sub2_path, "link")
- t2_path = join(test_support.TESTFN, "TEST2")
- tmp4_path = join(test_support.TESTFN, "TEST2", "tmp4")
+ t2_path = join(support.TESTFN, "TEST2")
+ tmp4_path = join(support.TESTFN, "TEST2", "tmp4")
# Create stuff.
os.makedirs(sub11_path)
# Windows, which doesn't have a recursive delete command. The
# (not so) subtlety is that rmdir will fail unless the dir's
# kids are removed first, so bottom up is essential.
- for root, dirs, files in os.walk(test_support.TESTFN, topdown=False):
+ for root, dirs, files in os.walk(support.TESTFN, topdown=False):
for name in files:
os.remove(os.path.join(root, name))
for name in dirs:
os.rmdir(dirname)
else:
os.remove(dirname)
- os.rmdir(test_support.TESTFN)
+ os.rmdir(support.TESTFN)
class MakedirTests(unittest.TestCase):
def setUp(self):
- os.mkdir(test_support.TESTFN)
+ os.mkdir(support.TESTFN)
def test_makedir(self):
- base = test_support.TESTFN
+ base = support.TESTFN
path = os.path.join(base, 'dir1', 'dir2', 'dir3')
os.makedirs(path) # Should work
path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4')
os.makedirs(path)
def tearDown(self):
- path = os.path.join(test_support.TESTFN, 'dir1', 'dir2', 'dir3',
+ path = os.path.join(support.TESTFN, 'dir1', 'dir2', 'dir3',
'dir4', 'dir5', 'dir6')
# If the tests failed, the bottom-most directory ('../dir6')
# may not have been created, so we look for the outermost directory
# that exists.
- while not os.path.exists(path) and path != test_support.TESTFN:
+ while not os.path.exists(path) and path != support.TESTFN:
path = os.path.dirname(path)
os.removedirs(path)
class Win32ErrorTests(unittest.TestCase):
def test_rename(self):
- self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak")
+ self.assertRaises(WindowsError, os.rename, support.TESTFN, support.TESTFN+".bak")
def test_remove(self):
- self.assertRaises(WindowsError, os.remove, test_support.TESTFN)
+ self.assertRaises(WindowsError, os.remove, support.TESTFN)
def test_chdir(self):
- self.assertRaises(WindowsError, os.chdir, test_support.TESTFN)
+ self.assertRaises(WindowsError, os.chdir, support.TESTFN)
def test_mkdir(self):
- self.assertRaises(WindowsError, os.chdir, test_support.TESTFN)
+ self.assertRaises(WindowsError, os.chdir, support.TESTFN)
def test_utime(self):
- self.assertRaises(WindowsError, os.utime, test_support.TESTFN, None)
+ self.assertRaises(WindowsError, os.utime, support.TESTFN, None)
def test_access(self):
- self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0)
+ self.assertRaises(WindowsError, os.utime, support.TESTFN, 0)
def test_chmod(self):
- self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0)
+ self.assertRaises(WindowsError, os.utime, support.TESTFN, 0)
if sys.platform != 'win32':
class Win32ErrorTests(unittest.TestCase):
pass
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
FileTests,
StatAttributeTests,
EnvironTests,
-from test import test_support
-test_support.requires('audio')
+from test import support
+support.requires('audio')
-from test.test_support import findfile, TestSkipped
+from test.support import findfile, TestSkipped
import errno
import ossaudiodev
raise TestSkipped(msg)
raise
dsp.close()
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
import parser
import unittest
import sys
-from test import test_support
+from test import support
#
# First, we test that we can generate trees from valid source fragments,
self.assertRaises(MemoryError, parser.expr, e)
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
RoundtripLegalSyntaxTestCase,
IllegalSyntaxTestCase,
CompileTestCase,
def test_main(verbose=None):
import sys
- from test import test_support
+ from test import support
test_classes = (TestTranforms,)
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
import hmac
import unittest
from hashlib import md5, sha1, sha224, sha256, sha384, sha512
-from test import test_support
+from test import support
class Pep247Test(unittest.TestCase):
self.check_module(hmac, key=b'abc')
def test_main():
- test_support.run_unittest(Pep247Test)
+ support.run_unittest(Pep247Test)
if __name__ == '__main__':
test_main()
# This file is marked as binary in the CVS, to prevent MacCVS from recoding it.\r
\r
import unittest\r
-from test import test_support\r
+from test import support\r
\r
class PEP263Test(unittest.TestCase):\r
\r
self.fail()\r
\r
def test_main():\r
- test_support.run_unittest(PEP263Test)\r
+ support.run_unittest(PEP263Test)\r
\r
if __name__=="__main__":\r
test_main()\r
# Test the Unicode versions of normal file functions
# open, os.open, os.stat. os.listdir, os.rename, os.remove, os.mkdir, os.chdir, os.rmdir
import sys, os, unittest
-from test import test_support
+from test import support
if not os.path.supports_unicode_filenames:
- raise test_support.TestSkipped("test works only on NT+")
+ raise support.TestSkipped("test works only on NT+")
filenames = [
'abc',
os.rmdir(dirname)
class UnicodeFileTests(unittest.TestCase):
- files = [os.path.join(test_support.TESTFN, f) for f in filenames]
+ files = [os.path.join(support.TESTFN, f) for f in filenames]
def setUp(self):
try:
- os.mkdir(test_support.TESTFN)
+ os.mkdir(support.TESTFN)
except OSError:
pass
for name in self.files:
os.stat(name)
def tearDown(self):
- deltree(test_support.TESTFN)
+ deltree(support.TESTFN)
def _apply_failure(self, fn, filename, expected_exception,
check_fn_in_exception = True):
try:
fn(filename)
- raise test_support.TestFailed("Expected to fail calling '%s(%r)'"
+ raise support.TestFailed("Expected to fail calling '%s(%r)'"
% (fn.__name__, filename))
except expected_exception as details:
if check_fn_in_exception and details.filename != filename:
- raise test_support.TestFailed("Function '%s(%r) failed with "
+ raise support.TestFailed("Function '%s(%r) failed with "
"bad filename in the exception: %r"
% (fn.__name__, filename,
details.filename))
os.stat(name)
def test_listdir(self):
- f1 = os.listdir(test_support.TESTFN)
- f2 = os.listdir(str(test_support.TESTFN.encode("utf-8"),
+ f1 = os.listdir(support.TESTFN)
+ f2 = os.listdir(str(support.TESTFN.encode("utf-8"),
sys.getfilesystemencoding()))
- sf2 = set("\\".join((str(test_support.TESTFN), f))
+ sf2 = set("\\".join((str(support.TESTFN), f))
for f in f2)
self.failUnlessEqual(len(f1), len(self.files))
self.failUnlessEqual(sf2, set(self.files))
os.rename("tmp",name)
def test_directory(self):
- dirname = os.path.join(test_support.TESTFN,'Gr\xfc\xdf-\u66e8\u66e9\u66eb')
+ dirname = os.path.join(support.TESTFN,'Gr\xfc\xdf-\u66e8\u66e9\u66eb')
filename = '\xdf-\u66e8\u66e9\u66eb'
oldwd = os.getcwd()
os.mkdir(dirname)
def test_main():
try:
- test_support.run_unittest(UnicodeFileTests)
+ support.run_unittest(UnicodeFileTests)
finally:
- deltree(test_support.TESTFN)
+ deltree(support.TESTFN)
if __name__ == "__main__":
test_main()
def test_main():
- from test import test_support
+ from test import support
test_classes = [TestTemplate,]
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
if __name__ == '__main__':
# This file is marked as binary in the CVS, to prevent MacCVS from recoding it.
import unittest
-from test import test_support
+from test import support
class PEP3120Test(unittest.TestCase):
self.fail("expected exception didn't occur")
def test_main():
- test_support.run_unittest(PEP3120Test)
+ support.run_unittest(PEP3120Test)
if __name__=="__main__":
test_main()
# -*- coding: utf-8 -*-
import unittest
-from test import test_support
+from test import support
class PEP3131Test(unittest.TestCase):
self.fail("expected exception didn't occur")
def test_main():
- test_support.run_unittest(PEP3131Test)
+ support.run_unittest(PEP3131Test)
if __name__=="__main__":
test_main()
import unittest
import builtins
import warnings
-from test.test_support import run_unittest
+from test.support import run_unittest
import os
from platform import system as platform_system
import pickle
import io
-from test import test_support
+from test import support
from test.pickletester import AbstractPickleTests
from test.pickletester import AbstractPickleModuleTests
return u.load()
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
PickleTests,
PicklerTests,
PersPicklerTests
)
- test_support.run_doctest(pickle)
+ support.run_doctest(pickle)
if __name__ == "__main__":
test_main()
import pickle
import pickletools
-from test import test_support
+from test import support
from test.pickletester import AbstractPickleTests
from test.pickletester import AbstractPickleModuleTests
error = KeyError
def test_main():
- test_support.run_unittest(OptimizedPickleTests)
- test_support.run_doctest(pickletools)
+ support.run_unittest(OptimizedPickleTests)
+ support.run_doctest(pickletools)
if __name__ == "__main__":
import os
import string
import unittest
-from test.test_support import TESTFN, run_unittest, unlink, TestSkipped
+from test.support import TESTFN, run_unittest, unlink, TestSkipped
if os.name != 'posix':
raise TestSkipped('pipes module only works on posix')
import tempfile
import textwrap
import unittest
-from test import test_support
+from test import support
# Helpers to create and destroy hierarchies.
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
import os, sys, string, random, tempfile, unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
class TestImport(unittest.TestCase):
-from test.test_support import run_unittest
+from test.support import run_unittest
import unittest
import sys
import imp
import unittest
import platform
-from test import test_support
+from test import support
class PlatformTest(unittest.TestCase):
def test_architecture(self):
res = platform.libc_ver(sys.executable)
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
PlatformTest
)
import plistlib
import os
import datetime
-from test import test_support
+from test import support
# This test data was generated through Cocoa's NSDictionary class
def tearDown(self):
try:
- os.unlink(test_support.TESTFN)
+ os.unlink(support.TESTFN)
except:
pass
def test_io(self):
pl = self._create()
- plistlib.writePlist(pl, test_support.TESTFN)
- pl2 = plistlib.readPlist(test_support.TESTFN)
+ plistlib.writePlist(pl, support.TESTFN)
+ pl2 = plistlib.readPlist(support.TESTFN)
self.assertEqual(dict(pl), dict(pl2))
def test_bytes(self):
def test_main():
- test_support.run_unittest(TestPlistlib)
+ support.run_unittest(TestPlistlib)
if __name__ == '__main__':
# Test case for the os.poll() function
import os, select, random, unittest
-from test.test_support import TestSkipped, TESTFN, run_unittest
+from test.support import TestSkipped, TESTFN, run_unittest
try:
select.poll
"""
import unittest
-from test import test_support
+from test import support
import os, sys
# Test that command-lines get down as we expect.
'foo "a \\"quoted\\" arg" bar',
["foo", 'a "quoted" arg', "bar"]
)
- test_support.reap_children()
+ support.reap_children()
def test_main():
- test_support.run_unittest(PopenTest)
+ support.run_unittest(PopenTest)
if __name__ == "__main__":
test_main()
import time
from unittest import TestCase
-from test import test_support
+from test import support
-HOST = test_support.HOST
+HOST = support.HOST
def server(evt, serv):
serv.listen(5)
self.evt = threading.Event()
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.settimeout(3)
- self.port = test_support.bind_port(self.sock)
+ self.port = support.bind_port(self.sock)
threading.Thread(target=server, args=(self.evt,self.sock)).start()
time.sleep(.1)
def test_main(verbose=None):
- test_support.run_unittest(GeneralTests)
+ support.run_unittest(GeneralTests)
if __name__ == '__main__':
test_main()
"Test posix functions"
-from test import test_support
+from test import support
try:
import posix
except ImportError:
- raise test_support.TestSkipped("posix is not available")
+ raise support.TestSkipped("posix is not available")
import time
import os
def setUp(self):
# create empty file
- fp = open(test_support.TESTFN, 'w+')
+ fp = open(support.TESTFN, 'w+')
fp.close()
def tearDown(self):
- os.unlink(test_support.TESTFN)
+ os.unlink(support.TESTFN)
def testNoArgFunctions(self):
# test posix functions which take no arguments and have
def test_fstatvfs(self):
if hasattr(posix, 'fstatvfs'):
- fp = open(test_support.TESTFN)
+ fp = open(support.TESTFN)
try:
self.assert_(posix.fstatvfs(fp.fileno()))
finally:
def test_ftruncate(self):
if hasattr(posix, 'ftruncate'):
- fp = open(test_support.TESTFN, 'w+')
+ fp = open(support.TESTFN, 'w+')
try:
# we need to have some data to truncate
fp.write('test')
def test_dup(self):
if hasattr(posix, 'dup'):
- fp = open(test_support.TESTFN)
+ fp = open(support.TESTFN)
try:
fd = posix.dup(fp.fileno())
self.assert_(isinstance(fd, int))
def test_dup2(self):
if hasattr(posix, 'dup2'):
- fp1 = open(test_support.TESTFN)
- fp2 = open(test_support.TESTFN)
+ fp1 = open(support.TESTFN)
+ fp2 = open(support.TESTFN)
try:
posix.dup2(fp1.fileno(), fp2.fileno())
finally:
fp2.close()
def fdopen_helper(self, *args):
- fd = os.open(test_support.TESTFN, os.O_RDONLY)
+ fd = os.open(support.TESTFN, os.O_RDONLY)
fp2 = posix.fdopen(fd, *args)
fp2.close()
def test_osexlock(self):
if hasattr(posix, "O_EXLOCK"):
- fd = os.open(test_support.TESTFN,
+ fd = os.open(support.TESTFN,
os.O_WRONLY|os.O_EXLOCK|os.O_CREAT)
- self.assertRaises(OSError, os.open, test_support.TESTFN,
+ self.assertRaises(OSError, os.open, support.TESTFN,
os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK)
os.close(fd)
if hasattr(posix, "O_SHLOCK"):
- fd = os.open(test_support.TESTFN,
+ fd = os.open(support.TESTFN,
os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
- self.assertRaises(OSError, os.open, test_support.TESTFN,
+ self.assertRaises(OSError, os.open, support.TESTFN,
os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK)
os.close(fd)
def test_osshlock(self):
if hasattr(posix, "O_SHLOCK"):
- fd1 = os.open(test_support.TESTFN,
+ fd1 = os.open(support.TESTFN,
os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
- fd2 = os.open(test_support.TESTFN,
+ fd2 = os.open(support.TESTFN,
os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
os.close(fd2)
os.close(fd1)
if hasattr(posix, "O_EXLOCK"):
- fd = os.open(test_support.TESTFN,
+ fd = os.open(support.TESTFN,
os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
- self.assertRaises(OSError, os.open, test_support.TESTFN,
+ self.assertRaises(OSError, os.open, support.TESTFN,
os.O_RDONLY|os.O_EXLOCK|os.O_NONBLOCK)
os.close(fd)
def test_fstat(self):
if hasattr(posix, 'fstat'):
- fp = open(test_support.TESTFN)
+ fp = open(support.TESTFN)
try:
self.assert_(posix.fstat(fp.fileno()))
finally:
def test_stat(self):
if hasattr(posix, 'stat'):
- self.assert_(posix.stat(test_support.TESTFN))
+ self.assert_(posix.stat(support.TESTFN))
if hasattr(posix, 'chown'):
def test_chown(self):
# raise an OSError if the file does not exist
- os.unlink(test_support.TESTFN)
- self.assertRaises(OSError, posix.chown, test_support.TESTFN, -1, -1)
+ os.unlink(support.TESTFN)
+ self.assertRaises(OSError, posix.chown, support.TESTFN, -1, -1)
# re-create the file
- open(test_support.TESTFN, 'w').close()
+ open(support.TESTFN, 'w').close()
if os.getuid() == 0:
try:
# Many linux distros have a nfsnobody user as MAX_UID-2
# This part of the test only runs when run as root.
# Only scary people run their tests as root.
ent = pwd.getpwnam('nfsnobody')
- posix.chown(test_support.TESTFN, ent.pw_uid, ent.pw_gid)
+ posix.chown(support.TESTFN, ent.pw_uid, ent.pw_gid)
except KeyError:
pass
else:
# non-root cannot chown to root, raises OSError
self.assertRaises(OSError, posix.chown,
- test_support.TESTFN, 0, 0)
+ support.TESTFN, 0, 0)
# test a successful chown call
- posix.chown(test_support.TESTFN, os.getuid(), os.getgid())
+ posix.chown(support.TESTFN, os.getuid(), os.getgid())
def test_chdir(self):
if hasattr(posix, 'chdir'):
posix.chdir(os.curdir)
- self.assertRaises(OSError, posix.chdir, test_support.TESTFN)
+ self.assertRaises(OSError, posix.chdir, support.TESTFN)
def test_lsdir(self):
if hasattr(posix, 'lsdir'):
- self.assert_(test_support.TESTFN in posix.lsdir(os.curdir))
+ self.assert_(support.TESTFN in posix.lsdir(os.curdir))
def test_access(self):
if hasattr(posix, 'access'):
- self.assert_(posix.access(test_support.TESTFN, os.R_OK))
+ self.assert_(posix.access(support.TESTFN, os.R_OK))
def test_umask(self):
if hasattr(posix, 'umask'):
def test_utime(self):
if hasattr(posix, 'utime'):
now = time.time()
- posix.utime(test_support.TESTFN, None)
- self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, None))
- self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (now, None))
- self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, now))
- posix.utime(test_support.TESTFN, (int(now), int(now)))
- posix.utime(test_support.TESTFN, (now, now))
+ posix.utime(support.TESTFN, None)
+ self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, None))
+ self.assertRaises(TypeError, posix.utime, support.TESTFN, (now, None))
+ self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, now))
+ posix.utime(support.TESTFN, (int(now), int(now)))
+ posix.utime(support.TESTFN, (now, now))
def test_chflags(self):
if hasattr(posix, 'chflags'):
- st = os.stat(test_support.TESTFN)
+ st = os.stat(support.TESTFN)
if hasattr(st, 'st_flags'):
- posix.chflags(test_support.TESTFN, st.st_flags)
+ posix.chflags(support.TESTFN, st.st_flags)
def test_lchflags(self):
if hasattr(posix, 'lchflags'):
- st = os.stat(test_support.TESTFN)
+ st = os.stat(support.TESTFN)
if hasattr(st, 'st_flags'):
- posix.lchflags(test_support.TESTFN, st.st_flags)
+ posix.lchflags(support.TESTFN, st.st_flags)
def test_environ(self):
for k, v in posix.environ.items():
self.assertEqual(type(v), str)
def test_main():
- test_support.run_unittest(PosixTester)
+ support.run_unittest(PosixTester)
if __name__ == '__main__':
test_main()
import unittest
-from test import test_support
+from test import support
import posixpath, os
from posixpath import realpath, abspath, join, dirname, basename, relpath
# An absolute path to a temporary filename for testing. We can't rely on TESTFN
# being an absolute path, so we need this.
-ABSTFN = abspath(test_support.TESTFN)
+ABSTFN = abspath(support.TESTFN)
def safe_rmdir(dirname):
try:
def tearDown(self):
for suffix in ["", "1", "2"]:
- test_support.unlink(test_support.TESTFN + suffix)
- safe_rmdir(test_support.TESTFN + suffix)
+ support.unlink(support.TESTFN + suffix)
+ safe_rmdir(support.TESTFN + suffix)
def assertIs(self, a, b):
self.assert_(a is b)
self.assertNotEqual(s1[n:n+1], s2[n:n+1])
def test_getsize(self):
- f = open(test_support.TESTFN, "wb")
+ f = open(support.TESTFN, "wb")
try:
f.write(b"foo")
f.close()
- self.assertEqual(posixpath.getsize(test_support.TESTFN), 3)
+ self.assertEqual(posixpath.getsize(support.TESTFN), 3)
finally:
if not f.closed:
f.close()
def test_time(self):
- f = open(test_support.TESTFN, "wb")
+ f = open(support.TESTFN, "wb")
try:
f.write(b"foo")
f.close()
- f = open(test_support.TESTFN, "ab")
+ f = open(support.TESTFN, "ab")
f.write(b"bar")
f.close()
- f = open(test_support.TESTFN, "rb")
+ f = open(support.TESTFN, "rb")
d = f.read()
f.close()
self.assertEqual(d, b"foobar")
self.assert_(
- posixpath.getctime(test_support.TESTFN) <=
- posixpath.getmtime(test_support.TESTFN)
+ posixpath.getctime(support.TESTFN) <=
+ posixpath.getmtime(support.TESTFN)
)
finally:
if not f.closed:
f.close()
def test_islink(self):
- self.assertIs(posixpath.islink(test_support.TESTFN + "1"), False)
- f = open(test_support.TESTFN + "1", "wb")
+ self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
+ f = open(support.TESTFN + "1", "wb")
try:
f.write(b"foo")
f.close()
- self.assertIs(posixpath.islink(test_support.TESTFN + "1"), False)
+ self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
if hasattr(os, "symlink"):
- os.symlink(test_support.TESTFN + "1", test_support.TESTFN + "2")
- self.assertIs(posixpath.islink(test_support.TESTFN + "2"), True)
- os.remove(test_support.TESTFN + "1")
- self.assertIs(posixpath.islink(test_support.TESTFN + "2"), True)
- self.assertIs(posixpath.exists(test_support.TESTFN + "2"), False)
- self.assertIs(posixpath.lexists(test_support.TESTFN + "2"), True)
+ os.symlink(support.TESTFN + "1", support.TESTFN + "2")
+ self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
+ os.remove(support.TESTFN + "1")
+ self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
+ self.assertIs(posixpath.exists(support.TESTFN + "2"), False)
+ self.assertIs(posixpath.lexists(support.TESTFN + "2"), True)
finally:
if not f.close():
f.close()
self.assertRaises(TypeError, posixpath.islink)
def test_exists(self):
- self.assertIs(posixpath.exists(test_support.TESTFN), False)
- f = open(test_support.TESTFN, "wb")
+ self.assertIs(posixpath.exists(support.TESTFN), False)
+ f = open(support.TESTFN, "wb")
try:
f.write(b"foo")
f.close()
- self.assertIs(posixpath.exists(test_support.TESTFN), True)
- self.assertIs(posixpath.lexists(test_support.TESTFN), True)
+ self.assertIs(posixpath.exists(support.TESTFN), True)
+ self.assertIs(posixpath.lexists(support.TESTFN), True)
finally:
if not f.close():
f.close()
self.assertRaises(TypeError, posixpath.exists)
def test_isdir(self):
- self.assertIs(posixpath.isdir(test_support.TESTFN), False)
- f = open(test_support.TESTFN, "wb")
+ self.assertIs(posixpath.isdir(support.TESTFN), False)
+ f = open(support.TESTFN, "wb")
try:
f.write(b"foo")
f.close()
- self.assertIs(posixpath.isdir(test_support.TESTFN), False)
- os.remove(test_support.TESTFN)
- os.mkdir(test_support.TESTFN)
- self.assertIs(posixpath.isdir(test_support.TESTFN), True)
- os.rmdir(test_support.TESTFN)
+ self.assertIs(posixpath.isdir(support.TESTFN), False)
+ os.remove(support.TESTFN)
+ os.mkdir(support.TESTFN)
+ self.assertIs(posixpath.isdir(support.TESTFN), True)
+ os.rmdir(support.TESTFN)
finally:
if not f.close():
f.close()
self.assertRaises(TypeError, posixpath.isdir)
def test_isfile(self):
- self.assertIs(posixpath.isfile(test_support.TESTFN), False)
- f = open(test_support.TESTFN, "wb")
+ self.assertIs(posixpath.isfile(support.TESTFN), False)
+ f = open(support.TESTFN, "wb")
try:
f.write(b"foo")
f.close()
- self.assertIs(posixpath.isfile(test_support.TESTFN), True)
- os.remove(test_support.TESTFN)
- os.mkdir(test_support.TESTFN)
- self.assertIs(posixpath.isfile(test_support.TESTFN), False)
- os.rmdir(test_support.TESTFN)
+ self.assertIs(posixpath.isfile(support.TESTFN), True)
+ os.remove(support.TESTFN)
+ os.mkdir(support.TESTFN)
+ self.assertIs(posixpath.isfile(support.TESTFN), False)
+ os.rmdir(support.TESTFN)
finally:
if not f.close():
f.close()
self.assertRaises(TypeError, posixpath.isdir)
def test_samefile(self):
- f = open(test_support.TESTFN + "1", "wb")
+ f = open(support.TESTFN + "1", "wb")
try:
f.write(b"foo")
f.close()
self.assertIs(
posixpath.samefile(
- test_support.TESTFN + "1",
- test_support.TESTFN + "1"
+ support.TESTFN + "1",
+ support.TESTFN + "1"
),
True
)
# inode information and thus, that samefile() doesn't work
if hasattr(os, "symlink"):
os.symlink(
- test_support.TESTFN + "1",
- test_support.TESTFN + "2"
+ support.TESTFN + "1",
+ support.TESTFN + "2"
)
self.assertIs(
posixpath.samefile(
- test_support.TESTFN + "1",
- test_support.TESTFN + "2"
+ support.TESTFN + "1",
+ support.TESTFN + "2"
),
True
)
- os.remove(test_support.TESTFN + "2")
- f = open(test_support.TESTFN + "2", "wb")
+ os.remove(support.TESTFN + "2")
+ f = open(support.TESTFN + "2", "wb")
f.write(b"bar")
f.close()
self.assertIs(
posixpath.samefile(
- test_support.TESTFN + "1",
- test_support.TESTFN + "2"
+ support.TESTFN + "1",
+ support.TESTFN + "2"
),
False
)
self.assertRaises(TypeError, posixpath.samefile)
def test_samestat(self):
- f = open(test_support.TESTFN + "1", "wb")
+ f = open(support.TESTFN + "1", "wb")
try:
f.write(b"foo")
f.close()
self.assertIs(
posixpath.samestat(
- os.stat(test_support.TESTFN + "1"),
- os.stat(test_support.TESTFN + "1")
+ os.stat(support.TESTFN + "1"),
+ os.stat(support.TESTFN + "1")
),
True
)
# inode information and thus, that samefile() doesn't work
if hasattr(os, "symlink"):
if hasattr(os, "symlink"):
- os.symlink(test_support.TESTFN + "1", test_support.TESTFN + "2")
+ os.symlink(support.TESTFN + "1", support.TESTFN + "2")
self.assertIs(
posixpath.samestat(
- os.stat(test_support.TESTFN + "1"),
- os.stat(test_support.TESTFN + "2")
+ os.stat(support.TESTFN + "1"),
+ os.stat(support.TESTFN + "2")
),
True
)
- os.remove(test_support.TESTFN + "2")
- f = open(test_support.TESTFN + "2", "wb")
+ os.remove(support.TESTFN + "2")
+ f = open(support.TESTFN + "2", "wb")
f.write(b"bar")
f.close()
self.assertIs(
posixpath.samestat(
- os.stat(test_support.TESTFN + "1"),
- os.stat(test_support.TESTFN + "2")
+ os.stat(support.TESTFN + "1"),
+ os.stat(support.TESTFN + "2")
),
False
)
os.symlink(ABSTFN+"1", ABSTFN)
self.assertEqual(realpath(ABSTFN), ABSTFN+"1")
finally:
- test_support.unlink(ABSTFN)
+ support.unlink(ABSTFN)
def test_realpath_symlink_loops(self):
# Bug #930024, return the path unchanged if we get into an infinite
self.assertEqual(realpath(basename(ABSTFN)), ABSTFN)
finally:
os.chdir(old_path)
- test_support.unlink(ABSTFN)
- test_support.unlink(ABSTFN+"1")
- test_support.unlink(ABSTFN+"2")
+ support.unlink(ABSTFN)
+ support.unlink(ABSTFN+"1")
+ support.unlink(ABSTFN+"2")
def test_realpath_resolve_parents(self):
# We also need to resolve any symlinks in the parents of a relative
self.assertEqual(realpath("a"), ABSTFN + "/y/a")
finally:
os.chdir(old_path)
- test_support.unlink(ABSTFN + "/k")
+ support.unlink(ABSTFN + "/k")
safe_rmdir(ABSTFN + "/y")
safe_rmdir(ABSTFN)
self.assertEqual(realpath(basename(ABSTFN) + "/link-y/.."), ABSTFN + "/k")
finally:
os.chdir(old_path)
- test_support.unlink(ABSTFN + "/link-y")
+ support.unlink(ABSTFN + "/link-y")
safe_rmdir(ABSTFN + "/k/y")
safe_rmdir(ABSTFN + "/k")
safe_rmdir(ABSTFN)
self.assertEqual(realpath(base + "link/k"), ABSTFN + "/k")
finally:
os.chdir(old_path)
- test_support.unlink(ABSTFN + "link")
+ support.unlink(ABSTFN + "link")
safe_rmdir(ABSTFN + "/k")
safe_rmdir(ABSTFN)
os.getcwd = real_getcwd
def test_main():
- test_support.run_unittest(PosixPathTest)
+ support.run_unittest(PosixPathTest)
if __name__=="__main__":
test_main()
-import test.test_support, unittest
+import test.support, unittest
class PowTest(unittest.TestCase):
eq(expected, 1.0) # else we didn't push fiveto to evenness
def test_main():
- test.test_support.run_unittest(PowTest)
+ test.support.run_unittest(PowTest)
if __name__ == "__main__":
test_main()
import pprint
-import test.test_support
+import test.support
import unittest
import test.test_set
def test_main():
- test.test_support.run_unittest(QueryTestCase)
+ test.support.run_unittest(QueryTestCase)
if __name__ == "__main__":
from __future__ import print_function
import unittest
-from test import test_support
+from test import support
import sys
try:
end is not NotDefined,
file is not NotDefined)]
- with test_support.captured_stdout() as t:
+ with support.captured_stdout() as t:
fn(args, sep, end, file)
self.assertEqual(t.getvalue(), expected)
self.assertRaises(AttributeError, print, '', file='')
def test_main():
- test_support.run_unittest(TestPrint)
+ support.run_unittest(TestPrint)
if __name__ == "__main__":
test_main()
import unittest
from difflib import unified_diff
from io import StringIO
-from test.test_support import run_unittest
+from test.support import run_unittest
import profile
from test.profilee import testfunc, timer
import sys
import unittest
-from test import test_support
+from test import support
class TestGetProfile(unittest.TestCase):
def setUp(self):
except TypeError:
pass
else:
- raise test_support.TestFailed(
+ raise support.TestFailed(
'sys.setprofile() did not raise TypeError')
if p is None:
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
TestGetProfile,
ProfileHookTestCase,
ProfileSimulatorTestCase
# more tests are in test_descr
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
class PropertyBase(Exception):
pass
import unittest
-from test import test_support
+from test import support
import pstats
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
AddCallersTestCase
)
import os
import sys
import signal
-from test.test_support import verbose, TestSkipped, run_unittest
+from test.support import verbose, TestSkipped, run_unittest
import unittest
TEST_STRING_1 = "I wish to buy a fish license.\n"
import unittest
-from test import test_support
+from test import support
import pwd
self.assertRaises(KeyError, pwd.getpwuid, fakeuid)
def test_main():
- test_support.run_unittest(PwdTest)
+ support.run_unittest(PwdTest)
if __name__ == "__main__":
test_main()
Test cases for pyclbr.py
Nick Mathewson
'''
-from test.test_support import run_unittest
+from test.support import run_unittest
import sys
from types import FunctionType, MethodType, BuiltinFunctionType
import pyclbr
-from test import test_support\r
+from test import support\r
import unittest\r
import pydoc\r
\r
in pydoc.render_doc(c))\r
\r
def test_main():\r
- test_support.run_unittest(TestDescriptions)\r
+ support.run_unittest(TestDescriptions)\r
\r
if __name__ == "__main__":\r
unittest.main()\r
import pyexpat
from xml.parsers import expat
-from test.test_support import sortdict, run_unittest
+from test.support import sortdict, run_unittest
class SetAttributeTest(unittest.TestCase):
import threading
import time
import unittest
-from test import test_support
+from test import support
QUEUE_SIZE = 5
def test_main():
- test_support.run_unittest(QueueTest, LifoQueueTest, PriorityQueueTest,
+ support.run_unittest(QueueTest, LifoQueueTest, PriorityQueueTest,
FailingQueueTest)
-from test import test_support
+from test import support
import unittest
import sys, os, io, subprocess
self.assertEqual(cout.splitlines(), p.splitlines())
def test_main():
- test_support.run_unittest(QuopriTestCase)
+ support.run_unittest(QuopriTestCase)
if __name__ == "__main__":
"""Tests for the raise statement."""
-from test import test_support
+from test import support
import sys
import types
import unittest
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
import pickle
import warnings
from math import log, exp, sqrt, pi
-from test import test_support
+from test import support
class TestBasicOps(unittest.TestCase):
# Superclass with tests common to all generators.
("randv2_64.pck", 866),
("randv3.pck", 343)]
for file, value in files:
- f = open(test_support.findfile(file),"rb")
+ f = open(support.findfile(file),"rb")
r = pickle.load(f)
f.close()
self.assertEqual(r.randrange(1000), value)
else:
testclasses.append(SystemRandom_TestBasicOps)
- test_support.run_unittest(*testclasses)
+ support.run_unittest(*testclasses)
# verify reference counting
import sys
if verbose and hasattr(sys, "gettotalrefcount"):
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_unittest(*testclasses)
+ support.run_unittest(*testclasses)
counts[i] = sys.gettotalrefcount()
print(counts)
# Python test set -- built-in functions
-import test.test_support, unittest
+import test.support, unittest
import sys
import warnings
self.assertEqual(repr(range(1, 2, 3)), 'range(1, 2, 3)')
def test_main():
- test.test_support.run_unittest(RangeTest)
+ test.support.run_unittest(RangeTest)
if __name__ == "__main__":
test_main()
import sys
sys.path = ['.'] + sys.path
-from test.test_support import verbose, run_unittest, catch_warning
+from test.support import verbose, run_unittest, catch_warning
import re
from re import Scanner
import sys, os, traceback
import shutil
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
from reprlib import repr as r # Don't shadow builtin repr
from reprlib import Repr
import unittest
-from test import test_support
+from test import support
import resource
import time
limit_set = True
except ValueError:
limit_set = False
- f = open(test_support.TESTFN, "wb")
+ f = open(support.TESTFN, "wb")
try:
f.write(b"X" * 1024)
try:
finally:
if limit_set:
resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max))
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_fsize_toobig(self):
# Be sure that setrlimit is checking for really large values
pass
def test_main(verbose=None):
- test_support.run_unittest(ResourceTest)
+ support.run_unittest(ResourceTest)
if __name__ == "__main__":
test_main()
import rfc822
import unittest
-from test import test_support
+from test import support
try:
from io import StringIO
def test_main():
- test_support.run_unittest(MessageTestCase)
+ support.run_unittest(MessageTestCase)
if __name__ == "__main__":
# Tests for rich comparisons
import unittest
-from test import test_support
+from test import support
import operator
return self.x >= other
def __cmp__(self, other):
- raise test_support.TestFailed("Number.__cmp__() should not be called")
+ raise support.TestFailed("Number.__cmp__() should not be called")
def __repr__(self):
return "Number(%r)" % (self.x, )
raise TypeError("Vectors cannot be used in Boolean contexts")
def __cmp__(self, other):
- raise test_support.TestFailed("Vector.__cmp__() should not be called")
+ raise support.TestFailed("Vector.__cmp__() should not be called")
def __repr__(self):
return "Vector(%r)" % (self.data, )
self.assertEquals(str(e),
"unhashable type: 'DumbEqualityWithoutHash'")
else:
- raise test_support.TestFailed("Should not be here")
+ raise support.TestFailed("Should not be here")
def test_main():
- test_support.run_unittest(VectorTest, NumberTest, MiscTest, DictTest, ListTest, HashableTest)
+ support.run_unittest(VectorTest, NumberTest, MiscTest, DictTest, ListTest, HashableTest)
if __name__ == "__main__":
test_main()
import unittest, robotparser
import io
-from test import test_support
+from test import support
class RobotTestCase(unittest.TestCase):
def __init__(self, index, parser, url, good, agent):
class TestCase(unittest.TestCase):
def runTest(self):
- test_support.requires('network')
+ support.requires('network')
# whole site is password-protected.
url = 'http://mueblesmoraleda.com'
parser = robotparser.RobotFileParser()
self.assertEqual(parser.can_fetch("*", url+"/robots.txt"), False)
def test_main():
- test_support.run_unittest(tests)
+ support.run_unittest(tests)
TestCase().run()
if __name__=='__main__':
- test_support.Verbose = 1
+ support.Verbose = 1
test_main()
import os.path
import sys
import tempfile
-from test.test_support import verbose, run_unittest, forget
+from test.support import verbose, run_unittest, forget
from runpy import _run_code, _run_module_code, run_module
# Note: This module can't safely test _run_module_as_main as it
from xml.sax.expatreader import create_parser
from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
from io import StringIO
-from test.test_support import findfile, run_unittest
+from test.support import findfile, run_unittest
import unittest
import os
import unittest
-from test.test_support import check_syntax_error, run_unittest
+from test.support import check_syntax_error, run_unittest
import warnings
warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<test string>")
-from test import test_support
+from test import support
import unittest
import select
import os
def test_select(self):
if sys.platform[:3] in ('win', 'mac', 'os2', 'riscos'):
- if test_support.verbose:
+ if support.verbose:
print("Can't test select easily on", sys.platform)
return
cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done'
p = os.popen(cmd, 'r')
for tout in (0, 1, 2, 4, 8, 16) + (None,)*10:
- if test_support.verbose:
+ if support.verbose:
print('timeout =', tout)
rfd, wfd, xfd = select.select([p], [], [], tout)
if (rfd, wfd, xfd) == ([], [], []):
continue
if (rfd, wfd, xfd) == ([p], [], []):
line = p.readline()
- if test_support.verbose:
+ if support.verbose:
print(repr(line))
if not line:
- if test_support.verbose:
+ if support.verbose:
print('EOF')
break
continue
p.close()
def test_main():
- test_support.run_unittest(SelectTestCase)
- test_support.reap_children()
+ support.run_unittest(SelectTestCase)
+ support.reap_children()
if __name__ == "__main__":
test_main()
import unittest
-from test import test_support
+from test import support
from weakref import proxy
import operator
import copy
s = self.thetype([w])
w.value = s
try:
- fo = open(test_support.TESTFN, "w")
+ fo = open(support.TESTFN, "w")
fo.write(str(s))
fo.close()
- fo = open(test_support.TESTFN, "r")
+ fo = open(support.TESTFN, "r")
self.assertEqual(fo.read(), repr(s))
finally:
fo.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_do_not_rehash_dict_keys(self):
n = 10
def test_print(self):
try:
- fo = open(test_support.TESTFN, "w")
+ fo = open(support.TESTFN, "w")
fo.write(str(self.set))
fo.close()
- fo = open(test_support.TESTFN, "r")
+ fo = open(support.TESTFN, "r")
self.assertEqual(fo.read(), repr(self.set))
finally:
fo.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_length(self):
self.assertEqual(len(self.set), self.length)
TestGraphs,
)
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
def test_main(verbose=None):
import sys
- from test import test_support
+ from test import support
from test import test_setcomps
- test_support.run_doctest(test_setcomps, verbose)
+ support.run_doctest(test_setcomps, verbose)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_doctest(test_setcomps, verbose)
+ support.run_doctest(test_setcomps, verbose)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
import re
import sgmllib
import unittest
-from test import test_support
+from test import support
class EventCollector(sgmllib.SGMLParser):
# Just verify this code doesn't cause a hang.
CHUNK = 1024 # increasing this to 8212 makes the problem go away
- f = open(test_support.findfile('sgml_input.html'), encoding="latin-1")
+ f = open(support.findfile('sgml_input.html'), encoding="latin-1")
fp = sgmllib.SGMLParser()
while 1:
data = f.read(CHUNK)
def test_main():
- test_support.run_unittest(SGMLParserTestCase)
+ support.run_unittest(SGMLParserTestCase)
if __name__ == "__main__":
import unittest
import shelve
import glob
-from test import test_support
+from test import support
from collections import MutableMapping
from test.test_anydbm import dbm_iterator
def tearDown(self):
for f in glob.glob(self.fn+"*"):
- test_support.unlink(f)
+ support.unlink(f)
def test_ascii_file_shelf(self):
s = shelve.open(self.fn, protocol=0)
self._db = []
if not self._in_mem:
for f in glob.glob(self.fn+"*"):
- test_support.unlink(f)
+ support.unlink(f)
class TestAsciiFileShelve(TestShelveBase):
_args={'protocol':0}
def test_main():
for module in dbm_iterator():
- test_support.run_unittest(
+ support.run_unittest(
TestAsciiFileShelve,
TestBinaryFileShelve,
TestProto2FileShelve,
import os, sys, io
import shlex
-from test import test_support
+from test import support
# The original test data set was from shellwords, by Hartmut Goebel.
delattr(ShlexTest, methname)
def test_main():
- test_support.run_unittest(ShlexTest)
+ support.run_unittest(ShlexTest)
if __name__ == "__main__":
test_main()
import stat
import os
import os.path
-from test import test_support
-from test.test_support import TESTFN
+from test import support
+from test.support import TESTFN
class TestShutil(unittest.TestCase):
def test_rmtree_errors(self):
def test_main():
- test_support.run_unittest(TestShutil, TestMove)
+ support.run_unittest(TestShutil, TestMove)
if __name__ == '__main__':
test_main()
import unittest
-from test import test_support
+from test import support
from contextlib import closing, nested
import gc
import pickle
import sys, os, time, errno
if sys.platform[:3] in ('win', 'os2') or sys.platform == 'riscos':
- raise test_support.TestSkipped("Can't test signal on %s" % \
+ raise support.TestSkipped("Can't test signal on %s" % \
sys.platform)
def handlerA(self, signum, frame):
self.a_called = True
- if test_support.verbose:
+ if support.verbose:
print("handlerA invoked from signal %s at:\n%s" % (
signum, self.format_frame(frame, limit=1)))
def handlerB(self, signum, frame):
self.b_called = True
- if test_support.verbose:
+ if support.verbose:
print ("handlerB invoked from signal %s at:\n%s" % (
signum, self.format_frame(frame, limit=1)))
raise HandlerBCalled(signum, self.format_frame(frame))
# Let the sub-processes know who to send signals to.
pid = os.getpid()
- if test_support.verbose:
+ if support.verbose:
print("test runner's pid is", pid)
child = ignoring_eintr(subprocess.Popen, ['kill', '-HUP', str(pid)])
except HandlerBCalled:
self.assertTrue(self.b_called)
self.assertFalse(self.a_called)
- if test_support.verbose:
+ if support.verbose:
print("HandlerBCalled exception caught")
child = ignoring_eintr(subprocess.Popen, ['kill', '-USR2', str(pid)])
# may return early.
time.sleep(1)
except KeyboardInterrupt:
- if test_support.verbose:
+ if support.verbose:
print("KeyboardInterrupt (the alarm() went off)")
except:
self.fail("Some other exception woke us from pause: %s" %
def sig_alrm(self, *args):
self.hndl_called = True
- if test_support.verbose:
+ if support.verbose:
print("SIGALRM handler invoked", args)
def sig_vtalrm(self, *args):
elif self.hndl_count == 3:
# disable ITIMER_VIRTUAL, this function shouldn't be called anymore
signal.setitimer(signal.ITIMER_VIRTUAL, 0)
- if test_support.verbose:
+ if support.verbose:
print("last SIGVTALRM handler call")
self.hndl_count += 1
- if test_support.verbose:
+ if support.verbose:
print("SIGVTALRM handler invoked", args)
def sig_prof(self, *args):
self.hndl_called = True
signal.setitimer(signal.ITIMER_PROF, 0)
- if test_support.verbose:
+ if support.verbose:
print("SIGPROF handler invoked", args)
def test_itimer_exc(self):
def test_itimer_real(self):
self.itimer = signal.ITIMER_REAL
signal.setitimer(self.itimer, 1.0)
- if test_support.verbose:
+ if support.verbose:
print("\ncall pause()...")
signal.pause()
self.assertEqual(self.hndl_called, True)
def test_main():
- test_support.run_unittest(BasicSignalTests, InterProcessSignalTests,
+ support.run_unittest(BasicSignalTests, InterProcessSignalTests,
WakeupSignalTests, SiginterruptTest, ItimerTest)
"""
import unittest
-from test.test_support import TestSkipped, run_unittest, TESTFN
+from test.support import TestSkipped, run_unittest, TESTFN
import builtins
import os
import sys
# tests for slice objects; in particular the indices method.
import unittest
-from test import test_support
+from test import support
from pickle import loads, dumps
import sys
self.assertNotEqual(id(s), id(t))
def test_main():
- test_support.run_unittest(SliceTest)
+ support.run_unittest(SliceTest)
if __name__ == "__main__":
test_main()
import select
from unittest import TestCase
-from test import test_support
+from test import support
-HOST = test_support.HOST
+HOST = support.HOST
def server(evt, buf, serv):
serv.listen(5)
self.evt = threading.Event()
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.settimeout(15)
- self.port = test_support.bind_port(self.sock)
+ self.port = support.bind_port(self.sock)
servargs = (self.evt, b"220 Hola mundo\n", self.sock)
threading.Thread(target=server, args=servargs).start()
self.evt.wait()
self.serv_evt = threading.Event()
self.client_evt = threading.Event()
- self.port = test_support.find_unused_port()
+ self.port = support.find_unused_port()
self.serv = smtpd.DebuggingServer((HOST, self.port), ('nowhere', -1))
serv_args = (self.serv, self.serv_evt, self.client_evt)
threading.Thread(target=debugging_server, args=serv_args).start()
self.evt = threading.Event()
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.settimeout(15)
- self.port = test_support.bind_port(self.sock)
+ self.port = support.bind_port(self.sock)
servargs = (self.evt, b"199 no hello for you!\n", self.sock)
threading.Thread(target=server, args=servargs).start()
self.evt.wait()
def setUp(self):
self.serv_evt = threading.Event()
self.client_evt = threading.Event()
- self.port = test_support.find_unused_port()
+ self.port = support.find_unused_port()
self.serv = SimSMTPServer((HOST, self.port), ('nowhere', -1))
serv_args = (self.serv, self.serv_evt, self.client_evt)
threading.Thread(target=debugging_server, args=serv_args).start()
def test_main(verbose=None):
- test_support.run_unittest(GeneralTests, DebuggingServerTests,
+ support.run_unittest(GeneralTests, DebuggingServerTests,
NonConnectingTests,
BadHELOServerTests, SMTPSimTests)
#!/usr/bin/env python
import unittest
-from test import test_support
+from test import support
import errno
import socket
from weakref import proxy
import signal
-HOST = test_support.HOST
+HOST = support.HOST
MSG = b'Michael Gilfix was here\n'
class SocketTCPTest(unittest.TestCase):
def setUp(self):
self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.port = test_support.bind_port(self.serv)
+ self.port = support.bind_port(self.serv)
self.serv.listen(1)
def tearDown(self):
def setUp(self):
self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- self.port = test_support.bind_port(self.serv)
+ self.port = support.bind_port(self.serv)
def tearDown(self):
self.serv.close()
class NetworkConnectionNoServer(unittest.TestCase):
def testWithoutServer(self):
- port = test_support.find_unused_port()
+ port = support.find_unused_port()
self.failUnlessRaises(
socket.error,
lambda: socket.create_connection((HOST, port))
for line in f:
if line.startswith("tipc "):
return True
- if test_support.verbose:
+ if support.verbose:
print("TIPC module is not loaded, please 'sudo modprobe tipc'")
return False
tests.append(TIPCTest)
tests.append(TIPCThreadableTest)
- thread_info = test_support.threading_setup()
- test_support.run_unittest(*tests)
- test_support.threading_cleanup(*thread_info)
+ thread_info = support.threading_setup()
+ support.run_unittest(*tests)
+ support.threading_cleanup(*thread_info)
if __name__ == "__main__":
test_main()
import unittest
import socketserver
-import test.test_support
-from test.test_support import reap_children, verbose, TestSkipped
-from test.test_support import TESTFN as TEST_FILE
+import test.support
+from test.support import reap_children, verbose, TestSkipped
+from test.support import TESTFN as TEST_FILE
-test.test_support.requires("network")
+test.support.requires("network")
TEST_STR = b"hello world\n"
-HOST = test.test_support.HOST
+HOST = test.support.HOST
HAVE_UNIX_SOCKETS = hasattr(socket, "AF_UNIX")
HAVE_FORKING = hasattr(os, "fork") and os.name != "os2"
# If the import lock is held, the threads will hang
raise TestSkipped("can't run when import lock is held")
- test.test_support.run_unittest(SocketServerTest)
+ test.support.run_unittest(SocketServerTest)
if __name__ == "__main__":
test_main()
-from test import test_support
+from test import support
import random
import sys
import unittest
-verbose = test_support.verbose
+verbose = support.verbose
nerrors = 0
def CmpToKey(mycmp):
TestBugs,
)
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
-from test.test_support import run_unittest, TestSkipped
+from test.support import run_unittest, TestSkipped
try:
import _sqlite3
import sys
import unittest
-from test import test_support
+from test import support
import socket
import select
import errno
except ImportError:
skip_expected = True
-HOST = test_support.HOST
+HOST = support.HOST
CERTFILE = None
SVN_PYTHON_ORG_ROOT_CERT = None
def handle_error(prefix):
exc_format = ' '.join(traceback.format_exception(*sys.exc_info()))
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(prefix + exc_format)
class BasicTests(unittest.TestCase):
def testSSLconnect(self):
- if not test_support.is_resource_enabled('network'):
+ if not support.is_resource_enabled('network'):
return
s = ssl.wrap_socket(socket.socket(socket.AF_INET),
cert_reqs=ssl.CERT_NONE)
s.connect(("svn.python.org", 443))
c = s.getpeercert()
if c:
- raise test_support.TestFailed("Peer cert %s shouldn't be here!")
+ raise support.TestFailed("Peer cert %s shouldn't be here!")
s.close()
# this should fail because we have no verification certs
def testRAND(self):
v = ssl.RAND_status()
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n RAND_status is %d (%s)\n"
% (v, (v and "sufficient randomness") or
"insufficient randomness"))
# provided solely for this test, to exercise the certificate
# parsing code
p = ssl._ssl._test_decode_cert(CERTFILE, False)
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n" + pprint.pformat(p) + "\n")
def testDERtoPEM(self):
p2 = ssl.DER_cert_to_PEM_cert(d1)
d2 = ssl.PEM_cert_to_DER_cert(p2)
if (d1 != d2):
- raise test_support.TestFailed("PEM-to-DER or DER-to-PEM translation failed")
+ raise support.TestFailed("PEM-to-DER or DER-to-PEM translation failed")
class NetworkedTests(unittest.TestCase):
s.connect(("svn.python.org", 443))
c = s.getpeercert()
if c:
- raise test_support.TestFailed("Peer cert %s shouldn't be here!")
+ raise support.TestFailed("Peer cert %s shouldn't be here!")
s.close()
# this should fail because we have no verification certs
try:
s.connect(("svn.python.org", 443))
except ssl.SSLError as x:
- raise test_support.TestFailed("Unexpected exception %s" % x)
+ raise support.TestFailed("Unexpected exception %s" % x)
finally:
s.close()
else:
raise
s.close()
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\nNeeded %d calls to do_handshake() to establish session.\n" % count)
def testFetchServerCert(self):
pem = ssl.get_server_certificate(("svn.python.org", 443))
if not pem:
- raise test_support.TestFailed("No server certificate on svn.python.org:443!")
+ raise support.TestFailed("No server certificate on svn.python.org:443!")
return
pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=CERTFILE)
except ssl.SSLError as x:
#should fail
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("%s\n" % x)
else:
- raise test_support.TestFailed("Got server certificate %s for svn.python.org!" % pem)
+ raise support.TestFailed("Got server certificate %s for svn.python.org!" % pem)
pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=SVN_PYTHON_ORG_ROOT_CERT)
if not pem:
- raise test_support.TestFailed("No server certificate on svn.python.org:443!")
- if test_support.verbose:
+ raise support.TestFailed("No server certificate on svn.python.org:443!")
+ if support.verbose:
sys.stdout.write("\nVerified certificate for svn.python.org:443 is\n%s\n" % pem)
else:
if self.server.certreqs == ssl.CERT_REQUIRED:
cert = self.sslconn.getpeercert()
- if test_support.verbose and self.server.chatty:
+ if support.verbose and self.server.chatty:
sys.stdout.write(" client cert is " + pprint.pformat(cert) + "\n")
cert_binary = self.sslconn.getpeercert(True)
- if test_support.verbose and self.server.chatty:
+ if support.verbose and self.server.chatty:
sys.stdout.write(" cert binary is " + str(len(cert_binary)) + " bytes\n")
cipher = self.sslconn.cipher()
- if test_support.verbose and self.server.chatty:
+ if support.verbose and self.server.chatty:
sys.stdout.write(" server: connection cipher is now " + str(cipher) + "\n")
return True
self.running = False
self.close()
elif amsg.strip() == 'over':
- if test_support.verbose and self.server.connectionchatty:
+ if support.verbose and self.server.connectionchatty:
sys.stdout.write(" server: client closed connection\n")
self.close()
return
elif (self.server.starttls_server and
amsg.strip() == 'STARTTLS'):
- if test_support.verbose and self.server.connectionchatty:
+ if support.verbose and self.server.connectionchatty:
sys.stdout.write(" server: read STARTTLS from client, sending OK...\n")
self.write("OK\n".encode("ASCII", "strict"))
if not self.wrap_conn():
return
else:
- if (test_support.verbose and
+ if (support.verbose and
self.server.connectionchatty):
ctype = (self.sslconn and "encrypted") or "unencrypted"
sys.stdout.write(" server: read %s (%s), sending back %s (%s)...\n"
self.connectionchatty = connectionchatty
self.starttls_server = starttls_server
self.sock = socket.socket()
- self.port = test_support.bind_port(self.sock)
+ self.port = support.bind_port(self.sock)
self.flag = None
self.active = False
threading.Thread.__init__(self)
while self.active:
try:
newconn, connaddr = self.sock.accept()
- if test_support.verbose and self.chatty:
+ if support.verbose and self.chatty:
sys.stdout.write(' server: new connection from '
+ repr(connaddr) + '\n')
handler = self.ConnectionHandler(self, newconn, connaddr)
# we override this to suppress logging unless "verbose"
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(" server (%s:%d %s):\n [%s] %s\n" %
(self.server.server_address,
self.server.server_port,
self.flag = None
self.active = False
self.RootedHTTPRequestHandler.root = os.path.split(CERTFILE)[0]
- self.port = test_support.find_unused_port()
+ self.port = support.find_unused_port()
self.server = self.HTTPSServer(
(HOST, self.port), self.RootedHTTPRequestHandler, certfile)
threading.Thread.__init__(self)
def handle_read(self):
data = self.recv(1024)
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(" server: read %s from client\n" % repr(data))
if not data:
self.close()
self.send(str(data, 'ASCII', 'strict').lower().encode('ASCII', 'strict'))
def handle_close(self):
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(" server: closed connection %s\n" % self.socket)
def handle_error(self):
def handle_accept(self):
sock_obj, addr = self.accept()
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(" server: new connection from %s:%s\n" %addr)
self.ConnectionHandler(sock_obj, self.certfile)
def __init__(self, certfile):
self.flag = None
self.active = False
- self.port = test_support.find_unused_port()
+ self.port = support.find_unused_port()
self.server = self.EchoServer(self.port, certfile)
threading.Thread.__init__(self)
self.setDaemon(True)
ssl_version=ssl.PROTOCOL_TLSv1)
s.connect((HOST, server.port))
except ssl.SSLError as x:
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\nSSLError is %s\n" % x)
else:
- raise test_support.TestFailed(
+ raise support.TestFailed(
"Use of invalid cert should have failed!")
finally:
server.stop()
ssl_version=client_protocol)
s.connect((HOST, server.port))
except ssl.SSLError as x:
- raise test_support.TestFailed("Unexpected SSL error: " + str(x))
+ raise support.TestFailed("Unexpected SSL error: " + str(x))
except Exception as x:
- raise test_support.TestFailed("Unexpected exception: " + str(x))
+ raise support.TestFailed("Unexpected exception: " + str(x))
else:
if connectionchatty:
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(
" client: sending %s...\n" % (repr(indata)))
s.write(indata.encode('ASCII', 'strict'))
outdata = s.read()
if connectionchatty:
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(" client: read %s\n" % repr(outdata))
outdata = str(outdata, 'ASCII', 'strict')
if outdata != indata.lower():
- raise test_support.TestFailed(
+ raise support.TestFailed(
"bad data <<%s>> (%d) received; expected <<%s>> (%d)\n"
% (repr(outdata[:min(len(outdata),20)]), len(outdata),
repr(indata[:min(len(indata),20)].lower()), len(indata)))
s.write("over\n".encode("ASCII", "strict"))
if connectionchatty:
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(" client: closing connection.\n")
s.close()
finally:
certtype = "CERT_OPTIONAL"
elif certsreqs == ssl.CERT_REQUIRED:
certtype = "CERT_REQUIRED"
- if test_support.verbose:
+ if support.verbose:
formatstr = (expectedToWork and " %s->%s %s\n") or " {%s->%s} %s\n"
sys.stdout.write(formatstr %
(ssl.get_protocol_name(client_protocol),
serverParamsTest(CERTFILE, server_protocol, certsreqs,
CERTFILE, CERTFILE, client_protocol,
chatty=False, connectionchatty=False)
- except test_support.TestFailed:
+ except support.TestFailed:
if expectedToWork:
raise
else:
if not expectedToWork:
- raise test_support.TestFailed(
+ raise support.TestFailed(
"Client protocol %s succeeded with server protocol %s!"
% (ssl.get_protocol_name(client_protocol),
ssl.get_protocol_name(server_protocol)))
def testEcho (self):
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
serverParamsTest(CERTFILE, ssl.PROTOCOL_TLSv1, ssl.CERT_NONE,
CERTFILE, CERTFILE, ssl.PROTOCOL_TLSv1,
def testReadCert(self):
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
s2 = socket.socket()
server = ThreadedEchoServer(CERTFILE,
ssl_version=ssl.PROTOCOL_SSLv23)
s.connect((HOST, server.port))
except ssl.SSLError as x:
- raise test_support.TestFailed(
+ raise support.TestFailed(
"Unexpected SSL error: " + str(x))
except Exception as x:
- raise test_support.TestFailed(
+ raise support.TestFailed(
"Unexpected exception: " + str(x))
else:
if not s:
- raise test_support.TestFailed(
+ raise support.TestFailed(
"Can't SSL-handshake with test server")
cert = s.getpeercert()
if not cert:
- raise test_support.TestFailed(
+ raise support.TestFailed(
"Can't get peer certificate.")
cipher = s.cipher()
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(pprint.pformat(cert) + '\n')
sys.stdout.write("Connection cipher is " + str(cipher) + '.\n')
if 'subject' not in cert:
- raise test_support.TestFailed(
+ raise support.TestFailed(
"No subject field in certificate: %s." %
pprint.pformat(cert))
if ((('organizationName', 'Python Software Foundation'),)
not in cert['subject']):
- raise test_support.TestFailed(
+ raise support.TestFailed(
"Missing or invalid 'organizationName' field in certificate subject; "
"should be 'Python Software Foundation'.")
s.close()
listener_ready = threading.Event()
listener_gone = threading.Event()
- port = test_support.find_unused_port()
+ port = support.find_unused_port()
# `listener` runs in a thread. It opens a socket listening on
# PORT, and sits in an accept() until the main thread connects.
except IOError:
pass
else:
- raise test_support.TestFailed(
+ raise support.TestFailed(
'connecting to closed SSL socket should have failed')
t = threading.Thread(target=listener)
t.join()
def testProtocolSSL2(self):
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True)
tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL)
tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False)
def testProtocolSSL23(self):
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
try:
tryProtocolCombo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True)
- except test_support.TestFailed as x:
+ except support.TestFailed as x:
# this fails on some older versions of OpenSSL (0.9.7l, for instance)
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(
" SSL2 client to SSL23 server test unexpectedly failed:\n %s\n"
% str(x))
tryProtocolCombo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED)
def testProtocolSSL3(self):
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True)
tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_OPTIONAL)
tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False)
def testProtocolTLS1(self):
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
tryProtocolCombo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True)
tryProtocolCombo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_OPTIONAL)
s.setblocking(1)
s.connect((HOST, server.port))
except Exception as x:
- raise test_support.TestFailed("Unexpected exception: " + str(x))
+ raise support.TestFailed("Unexpected exception: " + str(x))
else:
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
for indata in msgs:
msg = indata.encode('ASCII', 'replace')
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(
" client: sending %s...\n" % repr(msg))
if wrapped:
outdata = s.recv(1024)
if (indata == "STARTTLS" and
str(outdata, 'ASCII', 'replace').strip().lower().startswith("ok")):
- if test_support.verbose:
+ if support.verbose:
msg = str(outdata, 'ASCII', 'replace')
sys.stdout.write(
" client: read %s from server, starting TLS...\n"
wrapped = True
else:
- if test_support.verbose:
+ if support.verbose:
msg = str(outdata, 'ASCII', 'replace')
sys.stdout.write(
" client: read %s from server\n" % repr(msg))
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(" client: closing connection.\n")
if wrapped:
conn.write("over\n".encode("ASCII", "strict"))
flag.wait()
# try to connect
try:
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write('\n')
d1 = open(CERTFILE, 'rb').read()
d2 = ''
dlen = f.info().getheader("content-length")
if dlen and (int(dlen) > 0):
d2 = f.read(int(dlen))
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(
" client: read %d bytes from remote server '%s'\n"
% (len(d2), server))
f.close()
except:
msg = ''.join(traceback.format_exception(*sys.exc_info()))
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write('\n' + msg)
- raise test_support.TestFailed(msg)
+ raise support.TestFailed(msg)
else:
if not (d1 == d2):
print("d1 is", len(d1), repr(d1))
print("d2 is", len(d2), repr(d2))
- raise test_support.TestFailed(
+ raise support.TestFailed(
"Couldn't fetch data from HTTPS server")
finally:
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write('stopping server\n')
server.stop()
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write('joining thread\n')
server.join()
def testAsyncoreServer(self):
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
indata="FOO\n"
s = ssl.wrap_socket(socket.socket())
s.connect((HOST, server.port))
except ssl.SSLError as x:
- raise test_support.TestFailed("Unexpected SSL error: " + str(x))
+ raise support.TestFailed("Unexpected SSL error: " + str(x))
except Exception as x:
- raise test_support.TestFailed("Unexpected exception: " + str(x))
+ raise support.TestFailed("Unexpected exception: " + str(x))
else:
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(
" client: sending %s...\n" % (repr(indata)))
s.sendall(indata.encode('ASCII', 'strict'))
outdata = s.recv()
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(" client: read %s\n" % repr(outdata))
outdata = str(outdata, 'ASCII', 'strict')
if outdata != indata.lower():
- raise test_support.TestFailed(
+ raise support.TestFailed(
"bad data <<%s>> (%d) received; expected <<%s>> (%d)\n"
% (repr(outdata[:min(len(outdata),20)]), len(outdata),
repr(indata[:min(len(indata),20)].lower()), len(indata)))
s.write("over\n".encode("ASCII", "strict"))
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(" client: closing connection.\n")
s.close()
finally:
def test_main(verbose=False):
if skip_expected:
- raise test_support.TestSkipped("No SSL support")
+ raise support.TestSkipped("No SSL support")
global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT
CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir,
if (not os.path.exists(CERTFILE) or
not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT)):
- raise test_support.TestFailed("Can't read certificate files!")
+ raise support.TestFailed("Can't read certificate files!")
tests = [BasicTests]
- if test_support.is_resource_enabled('network'):
+ if support.is_resource_enabled('network'):
tests.append(NetworkedTests)
if _have_threads:
- thread_info = test_support.threading_setup()
- if thread_info and test_support.is_resource_enabled('network'):
+ thread_info = support.threading_setup()
+ if thread_info and support.is_resource_enabled('network'):
tests.append(ThreadedTests)
- test_support.run_unittest(*tests)
+ support.run_unittest(*tests)
if _have_threads:
- test_support.threading_cleanup(*thread_info)
+ support.threading_cleanup(*thread_info)
if __name__ == "__main__":
test_main()
# call succeeded, but also the the script actually has run.
import unittest
-from test import test_support
+from test import support
# use this form so that the test is skipped when startfile is not available:
from os import startfile, path
startfile(empty, "open")
def test_main():
- test_support.run_unittest(TestCase)
+ support.run_unittest(TestCase)
if __name__=="__main__":
test_main()
import sys
import os
import re
-from test import test_support
+from test import support
import time
import unittest
self.strftest1(now)
self.strftest2(now)
- if test_support.verbose:
+ if support.verbose:
print("Strftime test, platform: %s, Python version: %s" % \
(sys.platform, sys.version.split()[0]))
self.strftest2(arg)
def strftest1(self, now):
- if test_support.verbose:
+ if support.verbose:
print("strftime test for", time.ctime(now))
now = self.now
# Make sure any characters that could be taken as regex syntax is
except ValueError as result:
msg = "Error for nonstandard '%s' format (%s): %s" % \
(e[0], e[2], str(result))
- if test_support.verbose:
+ if support.verbose:
print(msg)
continue
if re.match(escapestr(e[1], self.ampm), result):
- if test_support.verbose:
+ if support.verbose:
print("Supports nonstandard '%s' format (%s)" % (e[0], e[2]))
elif not result or result[0] == '%':
- if test_support.verbose:
+ if support.verbose:
print("Does not appear to support '%s' format (%s)" % \
(e[0], e[2]))
else:
- if test_support.verbose:
+ if support.verbose:
print("Conflict for nonstandard '%s' format (%s):" % \
(e[0], e[2]))
print(" Expected %s, but got %s" % (e[1], result))
def test_main():
- test_support.run_unittest(StrftimeTest)
+ support.run_unittest(StrftimeTest)
if __name__ == '__main__':
test_main()
import unittest, string
-from test import test_support
+from test import support
class ModuleTest(unittest.TestCase):
self.assertRaises(TypeError, string.maketrans, 'abc', 'def')
def test_main():
- test_support.run_unittest(ModuleTest)
+ support.run_unittest(ModuleTest)
if __name__ == "__main__":
test_main()
# Since we don't have them, this test checks only a few codepoints.
import unittest
-from test import test_support
+from test import support
from stringprep import *
# print p, h.hexdigest()
def test_main():
- test_support.run_unittest(StringprepTests)
+ support.run_unittest(StringprepTests)
if __name__ == '__main__':
test_main()
import locale
import re
import sys
-from test import test_support
+from test import support
from datetime import date as datetime_date
import _strptime
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
getlang_Tests,
LocaleTime_Tests,
TimeRETests,
-from test.test_support import TestFailed, verbose, verify, vereq
-import test.test_support
+from test.support import TestFailed, verbose, verify, vereq
+import test.support
import struct
import array
import warnings
def with_warning_restore(func):
def _with_warning_restore(*args, **kw):
- with test.test_support.catch_warning():
+ with test.support.catch_warning():
# Grrr, we need this function to warn every time. Without removing
# the warningregistry, running test_tarfile then test_struct would fail
# on 64-bit platforms.
LLONG_MAX, LLONG_MIN, ULLONG_MAX
import warnings, unittest, sys
-from test import test_support
+from test import support
ts=test_structmembersType(False, 1, 2, 3, 4, 5, 6, 7, 8,
9.99999, 10.1010101010)
self.assertEqual(w.category, RuntimeWarning)
def test_byte_max(self):
- with test_support.catch_warning() as w:
+ with support.catch_warning() as w:
ts.T_BYTE = CHAR_MAX+1
self.has_warned(w)
def test_byte_min(self):
- with test_support.catch_warning() as w:
+ with support.catch_warning() as w:
ts.T_BYTE = CHAR_MIN-1
self.has_warned(w)
def test_ubyte_max(self):
- with test_support.catch_warning() as w:
+ with support.catch_warning() as w:
ts.T_UBYTE = UCHAR_MAX+1
self.has_warned(w)
def test_short_max(self):
- with test_support.catch_warning() as w:
+ with support.catch_warning() as w:
ts.T_SHORT = SHRT_MAX+1
self.has_warned(w)
def test_short_min(self):
- with test_support.catch_warning() as w:
+ with support.catch_warning() as w:
ts.T_SHORT = SHRT_MIN-1
self.has_warned(w)
def test_ushort_max(self):
- with test_support.catch_warning() as w:
+ with support.catch_warning() as w:
ts.T_USHORT = USHRT_MAX+1
self.has_warned(w)
def test_main(verbose=None):
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main(verbose=True)
import unittest
-from test import test_support
+from test import support
import time
L[start:stop:step])
def test_main():
- test_support.run_unittest(StructSeqTest)
+ support.run_unittest(StructSeqTest)
if __name__ == "__main__":
test_main()
import unittest
-from test import test_support
+from test import support
import subprocess
import sys
import signal
def setUp(self):
# Try to minimize the number of children we have so this test
# doesn't crash on some buildbots (Alphas in particular).
- if hasattr(test_support, "reap_children"):
- test_support.reap_children()
+ if hasattr(support, "reap_children"):
+ support.reap_children()
def tearDown(self):
# Try to minimize the number of children we have so this test
# doesn't crash on some buildbots (Alphas in particular).
- if hasattr(test_support, "reap_children"):
- test_support.reap_children()
+ if hasattr(support, "reap_children"):
+ support.reap_children()
def mkstemp(self):
"""wrapper for mkstemp, calling mktemp if mkstemp is not available"""
def test_no_leaking(self):
# Make sure we leak no resources
- if (not hasattr(test_support, "is_resource_enabled") or
- test_support.is_resource_enabled("subprocess") and not mswindows):
+ if (not hasattr(support, "is_resource_enabled") or
+ support.is_resource_enabled("subprocess") and not mswindows):
max_handles = 1026 # too much for most UNIX systems
else:
max_handles = 65
self.assertNotEqual(p.wait(), 0)
def test_main():
- test_support.run_unittest(ProcessTestCase)
- if hasattr(test_support, "reap_children"):
- test_support.reap_children()
+ support.run_unittest(ProcessTestCase)
+ if hasattr(support, "reap_children"):
+ support.reap_children()
if __name__ == "__main__":
unittest.main() # XXX test_main()
"""Do a minimal test of all the modules that aren't otherwise tested."""
-from test import test_support
+from test import support
import sys
import unittest
import warnings
class TestUntestedModules(unittest.TestCase):
def test_at_least_import_untested_modules(self):
- with test_support.catch_warning():
+ with support.catch_warning():
import CGIHTTPServer
import aifc
import bdb
try:
import tty # not available on Windows
except ImportError:
- if test_support.verbose:
+ if support.verbose:
print("skipping tty")
import webbrowser
import xml
def test_main():
- test_support.run_unittest(TestUntestedModules)
+ support.run_unittest(TestUntestedModules)
if __name__ == "__main__":
test_main()
import sys
import unittest
-from test import test_support
+from test import support
class A:
def test_main():
- test_support.run_unittest(TestSuper)
+ support.run_unittest(TestSuper)
if __name__ == "__main__":
-from test import test_support
+from test import support
import symtable
import unittest
def test_main():
- test_support.run_unittest(SymtableTest)
+ support.run_unittest(SymtableTest)
if __name__ == '__main__':
test_main()
import unittest
import warnings
-from test import test_support
+from test import support
class SyntaxTestCase(unittest.TestCase):
self._check_error("int(base=10, '2')", "non-keyword arg")
def test_main():
- test_support.run_unittest(SyntaxTestCase)
+ support.run_unittest(SyntaxTestCase)
from test import test_syntax
- test_support.run_doctest(test_syntax, verbosity=True)
+ support.run_doctest(test_syntax, verbosity=True)
if __name__ == "__main__":
test_main()
# -*- coding: iso-8859-1 -*-
-import unittest, test.test_support
+import unittest, test.support
import sys, io
class SysModuleTest(unittest.TestCase):
#self.assert_(r[0][2] > 100, r[0][2])
def test_main():
- test.test_support.run_unittest(SysModuleTest)
+ test.support.run_unittest(SysModuleTest)
if __name__ == "__main__":
test_main()
import syslog
import unittest
-from test import test_support
+from test import support
# XXX(nnorwitz): This test sucks. I don't know of a platform independent way
# to verify that the messages were really logged.
syslog.LOG_UPTO(syslog.LOG_INFO)
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
import unittest
import tarfile
-from test import test_support
+from test import support
# Check for our compression modules.
try:
return md5(data).hexdigest()
def path(path):
- return test_support.findfile(path)
+ return support.findfile(path)
TEMPDIR = os.path.join(tempfile.gettempdir(), "test_tarfile_tmp")
tarname = path("testtar.tar")
]
try:
- test_support.run_unittest(*tests)
+ support.run_unittest(*tests)
finally:
if os.path.exists(TEMPDIR):
shutil.rmtree(TEMPDIR)
import unittest
import os
-from test import test_support
+from test import support
from Tkinter import Tcl
from _tkinter import TclError
os.environ['DISPLAY'] = old_display
def test_main():
- test_support.run_unittest(TclTest)
+ support.run_unittest(TclTest)
if __name__ == "__main__":
test_main()
import time
from unittest import TestCase
-from test import test_support
+from test import support
-HOST = test_support.HOST
+HOST = support.HOST
def server(evt, serv):
serv.listen(5)
self.evt = threading.Event()
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.settimeout(3)
- self.port = test_support.bind_port(self.sock)
+ self.port = support.bind_port(self.sock)
threading.Thread(target=server, args=(self.evt,self.sock)).start()
self.evt.wait()
self.evt.clear()
def test_main(verbose=None):
- test_support.run_unittest(GeneralTests)
+ support.run_unittest(GeneralTests)
if __name__ == '__main__':
test_main()
import warnings
import unittest
-from test import test_support
+from test import support
warnings.filterwarnings("ignore",
category=RuntimeWarning,
self.failIf(s in dict)
dict[s] = 1
- def test_supports_iter(self):
+ def supports_iter(self):
# _RandomNameSequence supports the iterator protocol
i = 0
if not has_spawnl:
return # ugh, can't use TestSkipped.
- if test_support.verbose:
+ if support.verbose:
v="v"
else:
v="q"
test_classes.append(test_TemporaryFile)
def test_main():
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
if __name__ == "__main__":
test_main()
#
import unittest
-from test import test_support
+from test import support
from textwrap import TextWrapper, wrap, fill, dedent
def test_main():
- test_support.run_unittest(WrapTestCase,
+ support.run_unittest(WrapTestCase,
LongWordTestCase,
IndentTestCases,
DedentTestCase)
import os
import unittest
import random
-from test import test_support
+from test import support
import thread
import time
def verbose_print(arg):
"""Helper function for printing out debugging output."""
- if test_support.verbose:
+ if support.verbose:
with _print_mutex:
print(arg)
self.done_mutex.release()
def test_main():
- test_support.run_unittest(ThreadRunningTests, BarrierTest)
+ support.run_unittest(ThreadRunningTests, BarrierTest)
if __name__ == "__main__":
test_main()
# randrange, and then Python hangs.
import thread
-from test.test_support import verbose, TestSkipped, TestFailed
+from test.support import verbose, TestSkipped, TestFailed
critical_section = thread.allocate_lock()
done = thread.allocate_lock()
import threading
import tempfile
-from test.test_support import threading_setup, threading_cleanup, run_unittest
+from test.support import threading_setup, threading_cleanup, run_unittest
import unittest
import io
from traceback import print_exc
# Very rudimentary test of threading module
-import test.test_support
-from test.test_support import verbose
+import test.support
+from test.support import verbose
import random
import sys
import threading
def test_main():
- test.test_support.run_unittest(ThreadTests,
+ test.support.run_unittest(ThreadTests,
ThreadingExceptionTests)
if __name__ == "__main__":
import unittest
from doctest import DocTestSuite
-from test import test_support
+from test import support
import threading
import weakref
import gc
setUp=setUp, tearDown=tearDown)
)
- test_support.run_unittest(suite)
+ support.run_unittest(suite)
if __name__ == '__main__':
test_main()
import signal
import os
import sys
-from test.test_support import run_unittest, TestSkipped
+from test.support import run_unittest, TestSkipped
if sys.platform[:3] in ('win', 'os2'):
raise TestSkipped("Can't test signal on %s" % sys.platform)
-from test import test_support
+from test import support
import time
import unittest
self.assert_(0 <= (t1-t0) < 0.2)
def test_main():
- test_support.run_unittest(TimeTestCase)
+ support.run_unittest(TimeTestCase)
if __name__ == "__main__":
"""Unit tests for socket timeout feature."""
import unittest
-from test import test_support
+from test import support
# This requires the 'network' resource as given on the regrtest command line.
-skip_expected = not test_support.is_resource_enabled('network')
+skip_expected = not support.is_resource_enabled('network')
import time
import socket
def test_main():
- test_support.requires('network')
- test_support.run_unittest(CreationTestCase, TimeoutTestCase)
+ support.requires('network')
+ support.run_unittest(CreationTestCase, TimeoutTestCase)
if __name__ == "__main__":
test_main()
... " print(x)\\n")
True
- >>> f = test_support.findfile("tokenize_tests.txt")
+ >>> f = support.findfile("tokenize_tests.txt")
>>> roundtrip(open(f, 'rb'))
True
>>> tempdir = os.path.dirname(f) or os.curdir
>>> testfiles = glob.glob(os.path.join(tempdir, "test*.py"))
- >>> if not test_support.is_resource_enabled("compiler"):
+ >>> if not support.is_resource_enabled("compiler"):
... testfiles = random.sample(testfiles, 10)
...
>>> for testfile in testfiles:
True
"""
-from test import test_support
+from test import support
from tokenize import (tokenize, _tokenize, untokenize, NUMBER, NAME, OP,
STRING, ENDMARKER, tok_name, detect_encoding)
from io import BytesIO
def test_main():
from test import test_tokenize
- test_support.run_doctest(test_tokenize, True)
- test_support.run_unittest(TestTokenizerAdheresToPep0263)
- test_support.run_unittest(Test_Tokenize)
- test_support.run_unittest(TestDetectEncoding)
- test_support.run_unittest(TestTokenize)
+ support.run_doctest(test_tokenize, True)
+ support.run_unittest(TestTokenizerAdheresToPep0263)
+ support.run_unittest(Test_Tokenize)
+ support.run_unittest(TestDetectEncoding)
+ support.run_unittest(TestTokenize)
if __name__ == "__main__":
test_main()
# Testing the line trace facility.
-from test import test_support
+from test import support
import unittest
import sys
import difflib
no_jump_without_trace_function()
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
TraceTestCase,
RaisingTraceFuncTestCase,
JumpTestCase
from io import StringIO
import sys
import unittest
-from test.test_support import run_unittest, is_jython, Error
+from test.support import run_unittest, is_jython, Error
import traceback
-from test import test_support, seq_tests
+from test import support, seq_tests
class TupleTest(seq_tests.CommonTest):
type2test = tuple
self.assertEqual(repr(a2), "(0, 1, 2)")
def test_main():
- test_support.run_unittest(TupleTest)
+ support.run_unittest(TupleTest)
if __name__=="__main__":
test_main()
"""Unit tests for __instancecheck__ and __subclasscheck__."""
import unittest
-from test import test_support
+from test import support
class ABC(type):
def test_main():
- test_support.run_unittest(TypeChecksTest)
+ support.run_unittest(TypeChecksTest)
if __name__ == "__main__":
# Python test set -- part 6, built-in types
-from test.test_support import run_unittest, run_with_locale
+from test.support import run_unittest, run_with_locale
import unittest
import sys
import locale
import unittest
-from test import test_support
+from test import support
class UnicodeNamesTest(unittest.TestCase):
)
def test_main():
- test_support.run_unittest(UnicodeNamesTest)
+ support.run_unittest(UnicodeNamesTest)
if __name__ == "__main__":
test_main()
"""Test compiler changes for unary ops (+, -, ~) introduced in Python 2.2"""
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
class UnaryOpTestCase(unittest.TestCase):
import sys
import unittest
import warnings
-from test import test_support, string_tests
+from test import support, string_tests
# Error handling (bad decoder return)
def search_function(encoding):
return '\u1234'
self.assertEqual('%s' % Wrapper(), '\u1234')
- @test_support.run_with_locale('LC_ALL', 'de_DE', 'fr_FR')
+ @support.run_with_locale('LC_ALL', 'de_DE', 'fr_FR')
def test_format_float(self):
# should not format with a comma, but always with C locale
self.assertEqual('1.0', '%.1f' % 1.0)
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
import unicodedata
import unittest
-from test.test_support import run_unittest, TestSkipped, TESTFN_UNICODE
-from test.test_support import TESTFN_ENCODING, TESTFN_UNICODE_UNENCODEABLE
+from test.support import run_unittest, TestSkipped, TESTFN_UNICODE
+from test.support import TESTFN_ENCODING, TESTFN_UNICODE_UNENCODEABLE
try:
TESTFN_UNICODE.encode(TESTFN_ENCODING)
except (UnicodeError, TypeError):
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
"""#"
-import unittest, test.test_support
+import unittest, test.support
import hashlib
encoding = 'utf-8'
self.assertEquals(self.db.lookup("GOTHIC LETTER FAIHU"), '\U00010346')
def test_main():
- test.test_support.run_unittest(
+ test.support.run_unittest(
UnicodeMiscTest,
UnicodeMethodsTest,
UnicodeFunctionsTest
TestCase.{assert,fail}* methods (some are tested implicitly)
"""
-from test import test_support
+from test import support
import unittest
from unittest import TestCase
import types
######################################################################
def test_main():
- test_support.run_unittest(Test_TestCase, Test_TestLoader,
+ support.run_unittest(Test_TestCase, Test_TestLoader,
Test_TestSuite, Test_TestResult, Test_FunctionTestCase,
Test_Assertions)
import unittest
import os
import sys
-from test import test_support
+from test import support
if not hasattr(sys.stdin, 'newlines'):
- raise test_support.TestSkipped(
+ raise support.TestSkipped(
"This Python does not have universal newline support")
FATX = 'x' * (2**14)
WRITEMODE = 'wb'
def setUp(self):
- fp = open(test_support.TESTFN, self.WRITEMODE)
+ fp = open(support.TESTFN, self.WRITEMODE)
data = self.DATA
if "b" in self.WRITEMODE:
data = data.encode("ascii")
def tearDown(self):
try:
- os.unlink(test_support.TESTFN)
+ os.unlink(support.TESTFN)
except:
pass
def test_read(self):
- fp = open(test_support.TESTFN, self.READMODE)
+ fp = open(support.TESTFN, self.READMODE)
data = fp.read()
self.assertEqual(data, DATA_LF)
self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readlines(self):
- fp = open(test_support.TESTFN, self.READMODE)
+ fp = open(support.TESTFN, self.READMODE)
data = fp.readlines()
self.assertEqual(data, DATA_SPLIT)
self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readline(self):
- fp = open(test_support.TESTFN, self.READMODE)
+ fp = open(support.TESTFN, self.READMODE)
data = []
d = fp.readline()
while d:
self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_seek(self):
- fp = open(test_support.TESTFN, self.READMODE)
+ fp = open(support.TESTFN, self.READMODE)
fp.readline()
pos = fp.tell()
data = fp.readlines()
DATA = DATA_CRLF
def test_tell(self):
- fp = open(test_support.TESTFN, self.READMODE)
+ fp = open(support.TESTFN, self.READMODE)
self.assertEqual(repr(fp.newlines), repr(None))
data = fp.readline()
pos = fp.tell()
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
TestCRNewlines,
TestLFNewlines,
TestCRLFNewlines,
__test__ = {'doctests' : doctests}
def test_main(verbose=False):
- from test import test_support
+ from test import support
from test import test_unpack
- test_support.run_doctest(test_unpack, verbose)
+ support.run_doctest(test_unpack, verbose)
if __name__ == "__main__":
test_main(verbose=True)
def test_main(verbose=False):
import sys
- from test import test_support
+ from test import support
from test import test_unpack_ex
- test_support.run_doctest(test_unpack_ex, verbose)
+ support.run_doctest(test_unpack_ex, verbose)
if __name__ == "__main__":
test_main(verbose=True)
import httplib
import io
import unittest
-from test import test_support
+from test import support
import os
import mimetools
import tempfile
def setUp(self):
"""Setup of a temp file to use for testing"""
self.text = bytes("test_urllib: %s\n" % self.__class__.__name__, "ascii")
- FILE = open(test_support.TESTFN, 'wb')
+ FILE = open(support.TESTFN, 'wb')
try:
FILE.write(self.text)
finally:
FILE.close()
- self.pathname = test_support.TESTFN
+ self.pathname = support.TESTFN
self.returned_obj = urllib.urlopen("file:%s" % self.pathname)
def tearDown(self):
"""Shut down the open object"""
self.returned_obj.close()
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
def test_interface(self):
# Make sure object returned by urlopen() has the specified methods
self.tempFiles = []
# Create a temporary file.
- self.registerFileForCleanUp(test_support.TESTFN)
+ self.registerFileForCleanUp(support.TESTFN)
self.text = b'testing urllib.urlretrieve'
try:
- FILE = open(test_support.TESTFN, 'wb')
+ FILE = open(support.TESTFN, 'wb')
FILE.write(self.text)
FILE.close()
finally:
def test_basic(self):
# Make sure that a local file just gets its own location returned and
# a headers value is returned.
- result = urllib.urlretrieve("file:%s" % test_support.TESTFN)
- self.assertEqual(result[0], test_support.TESTFN)
+ result = urllib.urlretrieve("file:%s" % support.TESTFN)
+ self.assertEqual(result[0], support.TESTFN)
self.assert_(isinstance(result[1], mimetools.Message),
"did not get a mimetools.Message instance as second "
"returned value")
def test_copy(self):
# Test that setting the filename argument works.
- second_temp = "%s.2" % test_support.TESTFN
+ second_temp = "%s.2" % support.TESTFN
self.registerFileForCleanUp(second_temp)
result = urllib.urlretrieve(self.constructLocalFileUrl(
- test_support.TESTFN), second_temp)
+ support.TESTFN), second_temp)
self.assertEqual(second_temp, result[0])
self.assert_(os.path.exists(second_temp), "copy of the file was not "
"made")
self.assert_(isinstance(total_size, int))
self.assertEqual(count, count_holder[0])
count_holder[0] = count_holder[0] + 1
- second_temp = "%s.2" % test_support.TESTFN
+ second_temp = "%s.2" % support.TESTFN
self.registerFileForCleanUp(second_temp)
- urllib.urlretrieve(self.constructLocalFileUrl(test_support.TESTFN),
+ urllib.urlretrieve(self.constructLocalFileUrl(support.TESTFN),
second_temp, hooktester)
def test_reporthook_0_bytes(self):
_report.append((count, block_size, total_size))
srcFileName = self.createNewTempFile()
urllib.urlretrieve(self.constructLocalFileUrl(srcFileName),
- test_support.TESTFN, hooktester)
+ support.TESTFN, hooktester)
self.assertEqual(len(report), 1)
self.assertEqual(report[0][2], 0)
_report.append((count, block_size, total_size))
srcFileName = self.createNewTempFile(b"x" * 5)
urllib.urlretrieve(self.constructLocalFileUrl(srcFileName),
- test_support.TESTFN, hooktester)
+ support.TESTFN, hooktester)
self.assertEqual(len(report), 2)
self.assertEqual(report[0][1], 8192)
self.assertEqual(report[0][2], 5)
_report.append((count, block_size, total_size))
srcFileName = self.createNewTempFile(b"x" * 8193)
urllib.urlretrieve(self.constructLocalFileUrl(srcFileName),
- test_support.TESTFN, hooktester)
+ support.TESTFN, hooktester)
self.assertEqual(len(report), 3)
self.assertEqual(report[0][1], 8192)
self.assertEqual(report[0][2], 8193)
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
urlopen_FileTests,
urlopen_HttpTests,
urlretrieve_FileTests,
import unittest
-from test import test_support
+from test import support
import os
import io
h = urllib2.FileHandler()
o = h.parent = MockOpener()
- TESTFN = test_support.TESTFN
+ TESTFN = support.TESTFN
urlpath = sanepathname2url(os.path.abspath(TESTFN))
towrite = b"hello, world\n"
urls = [
def test_main(verbose=None):
from test import test_urllib2
- test_support.run_doctest(test_urllib2, verbose)
- test_support.run_doctest(urllib2, verbose)
+ support.run_doctest(test_urllib2, verbose)
+ support.run_doctest(urllib2, verbose)
tests = (TrivialTests,
OpenerDirectorTests,
HandlerTests,
MiscTests)
- test_support.run_unittest(*tests)
+ support.run_unittest(*tests)
if __name__ == "__main__":
test_main(verbose=True)
import BaseHTTPServer
import unittest
import hashlib
-from test import test_support
+from test import support
# Loopback http server infrastructure
# (Lib/test/regrtest.py -u network) since all tests here are only
# localhost. However, if this is a bad rationale, then uncomment
# the next line.
- #test_support.requires("network")
+ #support.requires("network")
- test_support.run_unittest(ProxyAuthTests)
- test_support.run_unittest(TestUrlopen)
+ support.run_unittest(ProxyAuthTests)
+ support.run_unittest(TestUrlopen)
if __name__ == "__main__":
test_main()
#!/usr/bin/env python
import unittest
-from test import test_support
+from test import support
from test.test_urllib2 import sanepathname2url
import socket
self._test_urls(urls, self._extra_handlers())
def test_file(self):
- TESTFN = test_support.TESTFN
+ TESTFN = support.TESTFN
f = open(TESTFN, 'w')
try:
f.write('hi there\n')
(expected_err, url, req, type(err), err))
self.assert_(isinstance(err, expected_err), msg)
else:
- with test_support.transient_internet():
+ with support.transient_internet():
buf = f.read()
f.close()
debug("read %d bytes" % len(buf))
def test_main():
- test_support.requires("network")
- test_support.run_unittest(AuthTests,
+ support.requires("network")
+ support.run_unittest(AuthTests,
OtherNetworkTests,
CloseSocketTest,
TimeoutTest,
#!/usr/bin/env python
import unittest
-from test import test_support
+from test import support
import socket
import urllib
def test_specified_path(self):
# Make sure that specifying the location of the file to write to works.
file_location,info = self.urlretrieve("http://www.python.org/",
- test_support.TESTFN)
- self.assertEqual(file_location, test_support.TESTFN)
+ support.TESTFN)
+ self.assertEqual(file_location, support.TESTFN)
self.assert_(os.path.exists(file_location))
FILE = open(file_location, errors='ignore')
try:
def test_main():
- test_support.requires('network')
- test_support.run_unittest(URLTimeoutTest,
+ support.requires('network')
+ support.run_unittest(URLTimeoutTest,
urlopenNetworkTests,
urlretrieveNetworkTests)
#! /usr/bin/env python
-from test import test_support
+from test import support
import unittest
import urlparse
('http', 'example.com', '', '', 'blahblah=/foo', ''))
def test_main():
- test_support.run_unittest(UrlParseTestCase)
+ support.run_unittest(UrlParseTestCase)
if __name__ == "__main__":
test_main()
# Check every path through every method of UserDict
-from test import test_support, mapping_tests
+from test import support, mapping_tests
import collections
d0 = {}
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
UserDictTest,
)
# Check every path through every method of UserList
from collections import UserList
-from test import test_support, list_tests
+from test import support, list_tests
class UserListTest(list_tests.CommonTest):
type2test = UserList
self.assertEqual(next(iter(T((1,2)))), "0!!!")
def test_main():
- test_support.run_unittest(UserListTest)
+ support.run_unittest(UserListTest)
if __name__ == "__main__":
test_main()
# UserString instances should behave similar to builtin string objects.
import string
-from test import test_support, string_tests
+from test import support, string_tests
from collections import UserString
def test_main():
- test_support.run_unittest(UserStringTest)
+ support.run_unittest(UserStringTest)
if __name__ == "__main__":
test_main()
"""
import unittest
-from test import test_support
+from test import support
import sys, os
import uu
pass
def setUp(self):
- self.tmpin = test_support.TESTFN + "i"
- self.tmpout = test_support.TESTFN + "o"
+ self.tmpin = support.TESTFN + "i"
+ self.tmpout = support.TESTFN + "o"
def tearDown(self):
del self.tmpin
def test_encode(self):
fin = fout = None
try:
- test_support.unlink(self.tmpin)
+ support.unlink(self.tmpin)
fin = open(self.tmpin, 'wb')
fin.write(plaintext)
fin.close()
def test_decode(self):
f = None
try:
- test_support.unlink(self.tmpin)
+ support.unlink(self.tmpin)
f = open(self.tmpin, 'wb')
f.write(encodedtextwrapped(0o644, self.tmpout))
f.close()
self._kill(f)
def test_main():
- test_support.run_unittest(UUTest,
+ support.run_unittest(UUTest,
UUStdIOTest,
UUFileTest,
)
from unittest import TestCase
-from test import test_support
+from test import support
import uuid
def importable(name):
def test_main():
- test_support.run_unittest(TestUUID)
+ support.run_unittest(TestUUID)
if __name__ == '__main__':
test_main()
import os
import time
from test.fork_wait import ForkWait
-from test.test_support import TestSkipped, run_unittest, reap_children
+from test.support import TestSkipped, run_unittest, reap_children
try:
os.fork
import os
import time
from test.fork_wait import ForkWait
-from test.test_support import TestSkipped, run_unittest, reap_children
+from test.support import TestSkipped, run_unittest, reap_children
try:
os.fork
from io import StringIO
import sys
import unittest
-from test import test_support
+from test import support
from test import warning_tests
"""Testing the filtering functionality."""
def test_error(self):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
self.module.resetwarnings()
self.module.filterwarnings("error", category=UserWarning)
self.assertRaises(UserWarning, self.module.warn,
"FilterTests.test_error")
def test_ignore(self):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
self.module.resetwarnings()
self.module.filterwarnings("ignore", category=UserWarning)
self.module.warn("FilterTests.test_ignore", UserWarning)
self.assert_(not w.message)
def test_always(self):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
self.module.resetwarnings()
self.module.filterwarnings("always", category=UserWarning)
message = "FilterTests.test_always"
self.assert_(w.message, message)
def test_default(self):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
self.module.resetwarnings()
self.module.filterwarnings("default", category=UserWarning)
message = UserWarning("FilterTests.test_default")
raise ValueError("loop variant unhandled")
def test_module(self):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
self.module.resetwarnings()
self.module.filterwarnings("module", category=UserWarning)
message = UserWarning("FilterTests.test_module")
self.assert_(not w.message, "unexpected message: " + str(w))
def test_once(self):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
self.module.resetwarnings()
self.module.filterwarnings("once", category=UserWarning)
message = UserWarning("FilterTests.test_once")
self.assert_(not w.message)
def test_inheritance(self):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
self.module.resetwarnings()
self.module.filterwarnings("error", category=Warning)
self.assertRaises(UserWarning, self.module.warn,
"FilterTests.test_inheritance", UserWarning)
def test_ordering(self):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
self.module.resetwarnings()
self.module.filterwarnings("ignore", category=UserWarning)
self.module.filterwarnings("error", category=UserWarning,
def test_filterwarnings(self):
# Test filterwarnings().
# Implicitly also tests resetwarnings().
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
self.module.filterwarnings("error", "", Warning, "", 0)
self.assertRaises(UserWarning, self.module.warn, 'convert to error')
"""Test warnings.warn() and warnings.warn_explicit()."""
def test_message(self):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
for i in range(4):
text = 'multi %d' %i # Different text on each call.
self.module.warn(text)
def test_filename(self):
with warnings_state(self.module):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
warning_tests.inner("spam1")
self.assertEqual(os.path.basename(w.filename), "warning_tests.py")
warning_tests.outer("spam2")
# Test stacklevel argument
# make sure all messages are different, so the warning won't be skipped
with warnings_state(self.module):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
warning_tests.inner("spam3", stacklevel=1)
self.assertEqual(os.path.basename(w.filename), "warning_tests.py")
warning_tests.outer("spam4", stacklevel=1)
try:
del warning_tests.__file__
with warnings_state(self.module):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
warning_tests.inner("spam8", stacklevel=1)
self.assertEqual(w.filename, warning_tests.__name__)
finally:
del warning_tests.__file__
warning_tests.__name__ = '__main__'
with warnings_state(self.module):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
warning_tests.inner('spam9', stacklevel=1)
self.assertEqual(w.filename, sys.argv[0])
finally:
warning_tests.__name__ = '__main__'
del sys.argv
with warnings_state(self.module):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
warning_tests.inner('spam10', stacklevel=1)
self.assertEqual(w.filename, '__main__')
finally:
warning_tests.__name__ = '__main__'
sys.argv = ['']
with warnings_state(self.module):
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
warning_tests.inner('spam11', stacklevel=1)
self.assertEqual(w.filename, '__main__')
finally:
def test_improper_input(self):
# Uses the private _setoption() function to test the parsing
# of command-line warning arguments
- with test_support.catch_warning(self.module):
+ with support.catch_warning(self.module):
self.assertRaises(self.module._OptionError,
self.module._setoption, '1:2:3:4:5:6')
self.assertRaises(self.module._OptionError,
def test_filter(self):
# Everything should function even if 'filters' is not in warnings.
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
self.module.filterwarnings("error", "", Warning, "", 0)
self.assertRaises(UserWarning, self.module.warn,
'convert to error')
try:
original_registry = self.module.onceregistry
__warningregistry__ = {}
- with test_support.catch_warning(self.module) as w:
+ with support.catch_warning(self.module) as w:
self.module.resetwarnings()
self.module.filterwarnings("once", category=UserWarning)
self.module.warn_explicit(message, UserWarning, "file", 42)
def test_showwarning_missing(self):
# Test that showwarning() missing is okay.
text = 'del showwarning test'
- with test_support.catch_warning(self.module):
+ with support.catch_warning(self.module):
self.module.filterwarnings("always", category=UserWarning)
del self.module.showwarning
- with test_support.captured_output('stderr') as stream:
+ with support.captured_output('stderr') as stream:
self.module.warn(text)
result = stream.getvalue()
self.failUnless(text in result)
def test_show_warning_output(self):
# With showarning() missing, make sure that output is okay.
text = 'test show_warning'
- with test_support.catch_warning(self.module):
+ with support.catch_warning(self.module):
self.module.filterwarnings("always", category=UserWarning)
del self.module.showwarning
- with test_support.captured_output('stderr') as stream:
+ with support.captured_output('stderr') as stream:
warning_tests.inner(text)
result = stream.getvalue()
self.failUnlessEqual(result.count('\n'), 2,
def test_main():
py_warnings.onceregistry.clear()
c_warnings.onceregistry.clear()
- test_support.run_unittest(CFilterTests,
+ support.run_unittest(CFilterTests,
PyFilterTests,
CWarnTests,
PyWarnTests,
-from test.test_support import TESTFN, run_unittest
+from test.support import TESTFN, run_unittest
import os
import wave
import unittest
import collections
import weakref
-from test import test_support
+from test import support
# Used in ReferencesTestCase.test_ref_created_during_del() .
ref_from_del = None
__test__ = {'libreftest' : libreftest}
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
ReferencesTestCase,
MappingTestCase,
WeakValueDictionaryTestCase,
WeakKeyDictionaryTestCase,
)
- test_support.run_doctest(sys.modules[__name__])
+ support.run_doctest(sys.modules[__name__])
if __name__ == "__main__":
import unittest
-from test import test_support
+from test import support
from weakref import proxy, ref, WeakSet
import operator
import copy
def test_main(verbose=None):
- test_support.run_unittest(TestWeakSet)
+ support.run_unittest(TestWeakSet)
if __name__ == "__main__":
test_main(verbose=True)
"""
import os
-import test.test_support
+import test.support
import unittest
import whichdb
import anydbm
import glob
from test.test_anydbm import delete_files, dbm_iterator
-_fname = test.test_support.TESTFN
+_fname = test.support.TESTFN
class WhichDBTestCase(unittest.TestCase):
# Actual test methods are added to namespace
name = module.__name__
if name == 'dumbdbm':
continue # whichdb can't support dumbdbm
- test.test_support.unlink(_fname)
+ test.support.unlink(_fname)
f = module.open(_fname, 'c')
f.close()
self.assertEqual(name, whichdb.whichdb(_fname))
def test_main():
try:
- test.test_support.run_unittest(WhichDBTestCase)
+ test.support.run_unittest(WhichDBTestCase)
finally:
delete_files()
import os, sys
import unittest
-from test import test_support
+from test import support
test_key_name = "SOFTWARE\\Python Registry Test Key - Delete Me"
self.assertEqual(r, os.environ["windir"] + "\\test")
def test_main():
- test_support.run_unittest(WinregTests)
+ support.run_unittest(WinregTests)
if __name__ == "__main__":
try:
# Ridiculously simple test of the winsound module for Windows.
import unittest
-from test import test_support
-test_support.requires('audio')
+from test import support
+support.requires('audio')
import winsound, time
import os
import subprocess
def test_main():
- test_support.run_unittest(BeepTest, MessageBeepTest, PlaySoundTest)
+ support.run_unittest(BeepTest, MessageBeepTest, PlaySoundTest)
if __name__=="__main__":
test_main()
import unittest
from collections import deque
from contextlib import GeneratorContextManager, contextmanager
-from test.test_support import run_unittest
+from test.support import run_unittest
class MockContextManager(GeneratorContextManager):
from socketserver import BaseServer
import re, sys
-from test import test_support
+from test import support
class MockServer(WSGIServer):
"""Non-socket HTTP server"""
# This epilogue is needed for compatibility with the Python 2.5 regrtest module
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
-from test import test_support
+from test import support
import unittest
import xdrlib
self.assertRaises(EOFError, up.unpack_uint)
def test_main():
- test_support.run_unittest(XDRTest)
+ support.run_unittest(XDRTest)
if __name__ == "__main__":
test_main()
import doctest
import sys
-from test import test_support
+from test import support
SAMPLE_XML = """
<body>
def test_main():
from test import test_xml_etree
- test_support.run_doctest(test_xml_etree, verbosity=True)
+ support.run_doctest(test_xml_etree, verbosity=True)
if __name__ == '__main__':
test_main()
import doctest
import sys
-from test import test_support
+from test import support
from xml.etree import cElementTree as ET
def test_main():
from test import test_xml_etree_c
- test_support.run_doctest(test_xml_etree_c, verbosity=True)
+ support.run_doctest(test_xml_etree_c, verbosity=True)
if __name__ == '__main__':
test_main()
import httplib
import socket
import os
-from test import test_support
+from test import support
alist = [{'astring': 'foo@bar.baz.spam',
'afloat': 7283.43,
# if the method is GET and no request_text is given, it runs handle_get
# get sysout output
tmp = sys.stdout
- sys.stdout = open(test_support.TESTFN, "w")
+ sys.stdout = open(support.TESTFN, "w")
self.cgi.handle_request()
sys.stdout.close()
sys.stdout = tmp
# parse Status header
- handle = open(test_support.TESTFN, "r").read()
+ handle = open(support.TESTFN, "r").read()
status = handle.split()[1]
message = ' '.join(handle.split()[2:4])
self.assertEqual(status, '400')
self.assertEqual(message, 'Bad Request')
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
os.environ['REQUEST_METHOD'] = ''
def test_cgi_xmlrpc_response(self):
tmp2 = sys.stdout
sys.stdin = open("xmldata.txt", "r")
- sys.stdout = open(test_support.TESTFN, "w")
+ sys.stdout = open(support.TESTFN, "w")
self.cgi.handle_request()
sys.stdout = tmp2
# will respond exception, if so, our goal is achieved ;)
- handle = open(test_support.TESTFN, "r").read()
+ handle = open(support.TESTFN, "r").read()
# start with 44th char so as not to get http header, we just need only xml
self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, handle[44:])
os.remove("xmldata.txt")
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
def test_main():
xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase,
xmlrpc_tests.append(FailingServerTestCase)
xmlrpc_tests.append(CGIHandlerTestCase)
- test_support.run_unittest(*xmlrpc_tests)
+ support.run_unittest(*xmlrpc_tests)
if __name__ == "__main__":
test_main()
import socket
import sys
import unittest
-from test import test_support
+from test import support
import xmlrpclib
def test_main():
- test_support.requires("network")
- test_support.run_unittest(CurrentTimeTest)
+ support.requires("network")
+ support.run_unittest(CurrentTimeTest)
if __name__ == "__main__":
test_main()
from tempfile import TemporaryFile
from random import randint, random
-import test.test_support as support
-from test.test_support import TESTFN, run_unittest
+import test.support as support
+from test.support import TESTFN, run_unittest
TESTFN2 = TESTFN + "2"
FIXEDTEST_SIZE = 1000
# Tests of the full ZIP64 functionality of zipfile
-# The test_support.requires call is the only reason for keeping this separate
+# The support.requires call is the only reason for keeping this separate
# from test_zipfile
-from test import test_support
+from test import support
# XXX(nnorwitz): disable this test by looking for extra largfile resource
# which doesn't exist. This test takes over 30 minutes to run in general
# and requires more disk space than most of the buildbots.
-test_support.requires(
+support.requires(
'extralargefile',
'test requires loads of disk-space bytes and a long time to run'
)
from io import StringIO
from tempfile import TemporaryFile
-from test.test_support import TESTFN, run_unittest
+from test.support import TESTFN, run_unittest
TESTFN2 = TESTFN + "2"
import zlib # implied prerequisite
from zipfile import ZipFile, ZipInfo, ZIP_STORED, ZIP_DEFLATED
-from test import test_support
+from test import support
from test.test_importhooks import ImportHooksBaseTestCase, test_src, test_co
import zipimport
self.assertZipFailure('A' * 33000)
def testEmptyFile(self):
- test_support.unlink(TESTMOD)
+ support.unlink(TESTMOD)
open(TESTMOD, 'w+').close()
self.assertZipFailure(TESTMOD)
def testFileUnreadable(self):
- test_support.unlink(TESTMOD)
+ support.unlink(TESTMOD)
fd = os.open(TESTMOD, os.O_CREAT, 000)
try:
os.close(fd)
# If we leave "the read-only bit" set on Windows, nothing can
# delete TESTMOD, and later tests suffer bogus failures.
os.chmod(TESTMOD, 0o666)
- test_support.unlink(TESTMOD)
+ support.unlink(TESTMOD)
def testNotZipFile(self):
- test_support.unlink(TESTMOD)
+ support.unlink(TESTMOD)
fp = open(TESTMOD, 'w+')
fp.write('a' * 22)
fp.close()
# XXX: disabled until this works on Big-endian machines
def _testBogusZipFile(self):
- test_support.unlink(TESTMOD)
+ support.unlink(TESTMOD)
fp = open(TESTMOD, 'w+')
fp.write(struct.pack('=I', 0x06054B50))
fp.write('a' * 18)
def test_main():
cleanup()
try:
- test_support.run_unittest(
+ support.run_unittest(
UncompressedZipImportTestCase,
CompressedZipImportTestCase,
BadFileZipImportTestCase,
)
finally:
- test_support.unlink(TESTMOD)
+ support.unlink(TESTMOD)
if __name__ == "__main__":
test_main()
import unittest
-from test import test_support
+from test import support
import zlib
import binascii
import random
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
ChecksumTestCase,
ExceptionTestCase,
CompressTestCase,
# standard library.
import sys
-import test.test_support
+import test.support
-test.test_support.verbose = 0
+test.support.verbose = 0
def runtest(name):
__import__(name)
- pdb gained the "until" command.
+- test.test_support has been renamed test.support
+
Build
-----