import sys
import unittest
import test.support
+from test.support import import_helper
from ctypes.util import find_library
libc_name = None
@unittest.skipUnless(os.name == "nt",
'test specific to Windows')
def test_load_dll_with_flags(self):
- _sqlite3 = test.support.import_module("_sqlite3")
+ _sqlite3 = import_helper.import_module("_sqlite3")
src = _sqlite3.__file__
if src.lower().endswith("_d.pyd"):
ext = "_d.dll"
import unittest
import sqlite3 as sqlite
-from test.support import TESTFN, unlink
+from test.support.os_helper import TESTFN, unlink
+
class CollationTests(unittest.TestCase):
def CheckCreateCollationNotString(self):
from test import support
from test.support import hashlib_helper
from test.support import import_helper
+from test.support import os_helper
from test.support import socket_helper
from test.support import threading_helper
+from test.support import warnings_helper
# Skip tests if _multiprocessing wasn't built.
@classmethod
def _test_child_fd_inflation(self, evt, q):
- q.put(test.support.fd_count())
+ q.put(os_helper.fd_count())
evt.wait()
def test_child_fd_inflation(self):
if self.TYPE == "threads":
self.skipTest('test not appropriate for {}'.format(self.TYPE))
- testfn = test.support.TESTFN
- self.addCleanup(test.support.unlink, testfn)
+ testfn = os_helper.TESTFN
+ self.addCleanup(os_helper.unlink, testfn)
proc = self.Process(target=self._test_stderr_flush, args=(testfn,))
proc.start()
proc.join()
if self.TYPE == 'threads':
self.skipTest('test not appropriate for {}'.format(self.TYPE))
- testfn = test.support.TESTFN
- self.addCleanup(test.support.unlink, testfn)
+ testfn = os_helper.TESTFN
+ self.addCleanup(os_helper.unlink, testfn)
for reason in (
[1, 2, 3],
close_queue(queue)
def test_no_import_lock_contention(self):
- with test.support.temp_cwd():
+ with os_helper.temp_cwd():
module_name = 'imported_by_an_imported_module'
with open(module_name + '.py', 'w') as f:
f.write("""if 1:
del q
""")
- with test.support.DirsOnSysPath(os.getcwd()):
+ with import_helper.DirsOnSysPath(os.getcwd()):
try:
__import__(module_name)
except pyqueue.Empty:
# force state to RUN to emit ResourceWarning in __del__()
pool._state = multiprocessing.pool.RUN
- with support.check_warnings(('unclosed running multiprocessing pool',
- ResourceWarning)):
+ with warnings_helper.check_warnings(
+ ('unclosed running multiprocessing pool', ResourceWarning)):
pool = None
support.gc_collect()
p = self.Process(target=self._writefd, args=(child_conn, b"foo"))
p.daemon = True
p.start()
- self.addCleanup(test.support.unlink, test.support.TESTFN)
- with open(test.support.TESTFN, "wb") as f:
+ self.addCleanup(os_helper.unlink, os_helper.TESTFN)
+ with open(os_helper.TESTFN, "wb") as f:
fd = f.fileno()
if msvcrt:
fd = msvcrt.get_osfhandle(fd)
reduction.send_handle(conn, fd, p.pid)
p.join()
- with open(test.support.TESTFN, "rb") as f:
+ with open(os_helper.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"foo")
@unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction")
p = self.Process(target=self._writefd, args=(child_conn, b"bar", True))
p.daemon = True
p.start()
- self.addCleanup(test.support.unlink, test.support.TESTFN)
- with open(test.support.TESTFN, "wb") as f:
+ self.addCleanup(os_helper.unlink, os_helper.TESTFN)
+ with open(os_helper.TESTFN, "wb") as f:
fd = f.fileno()
for newfd in range(256, MAXFD):
if not self._is_fd_assigned(newfd):
finally:
os.close(newfd)
p.join()
- with open(test.support.TESTFN, "rb") as f:
+ with open(os_helper.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"bar")
@classmethod
import unittest
from test import support
+from test.support import warnings_helper
import os
import sys
def check_all(self, modname):
names = {}
- with support.check_warnings(
+ with warnings_helper.check_warnings(
(".* (module|package)", DeprecationWarning),
(".* (module|package)", PendingDeprecationWarning),
("", ResourceWarning),
raise NoAll(modname)
names = {}
with self.subTest(module=modname):
- with support.check_warnings(
+ with warnings_helper.check_warnings(
("", DeprecationWarning),
("", ResourceWarning),
quiet=True):
from asyncio.proactor_events import _ProactorWritePipeTransport
from asyncio.proactor_events import _ProactorDuplexPipeTransport
from asyncio.proactor_events import _ProactorDatagramTransport
-from test import support
+from test.support import os_helper
from test.support import socket_helper
from test.test_asyncio import utils as test_utils
@classmethod
def setUpClass(cls):
- with open(support.TESTFN, 'wb') as fp:
+ with open(os_helper.TESTFN, 'wb') as fp:
fp.write(cls.DATA)
super().setUpClass()
@classmethod
def tearDownClass(cls):
- support.unlink(support.TESTFN)
+ os_helper.unlink(os_helper.TESTFN)
super().tearDownClass()
def setUp(self):
self.loop = asyncio.ProactorEventLoop()
self.set_event_loop(self.loop)
self.addCleanup(self.loop.close)
- self.file = open(support.TESTFN, 'rb')
+ self.file = open(os_helper.TESTFN, 'rb')
self.addCleanup(self.file.close)
super().setUp()
from test.support import os_helper
from test.support import TestFailed
from test.support.os_helper import FakePath
-from test import support, test_genericpath
+from test import test_genericpath
from tempfile import TemporaryFile
os.mkdir(ABSTFN)
self.addCleanup(os_helper.rmtree, ABSTFN)
- with support.change_cwd(ABSTFN):
+ with os_helper.change_cwd(ABSTFN):
os.mkdir("subdir")
os.chdir("subdir")
os.symlink(".", "recursive")
self.assertPathEqual(test_file_long, ntpath.realpath(test_file_short))
- with support.change_cwd(test_dir_long):
+ with os_helper.change_cwd(test_dir_long):
self.assertPathEqual(test_file_long, ntpath.realpath("file.txt"))
- with support.change_cwd(test_dir_long.lower()):
+ with os_helper.change_cwd(test_dir_long.lower()):
self.assertPathEqual(test_file_long, ntpath.realpath("file.txt"))
- with support.change_cwd(test_dir_short):
+ with os_helper.change_cwd(test_dir_short):
self.assertPathEqual(test_file_long, ntpath.realpath("file.txt"))
def test_expandvars(self):
# locations below cannot then refer to mount points
#
drive, path = ntpath.splitdrive(sys.executable)
- with support.change_cwd(ntpath.dirname(sys.executable)):
+ with os_helper.change_cwd(ntpath.dirname(sys.executable)):
self.assertFalse(ntpath.ismount(drive.lower()))
self.assertFalse(ntpath.ismount(drive.upper()))
from test import support
+from test.support import import_helper
support.requires('audio')
from test.support import findfile
-ossaudiodev = support.import_module('ossaudiodev')
+ossaudiodev = import_helper.import_module('ossaudiodev')
import errno
import sys
# using it, per
# http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
try:
- with support.EnvironmentVarGuard() as environ:
+ with os_helper.EnvironmentVarGuard() as environ:
if 'PROCESSOR_ARCHITEW6432' in environ:
del environ['PROCESSOR_ARCHITEW6432']
environ['PROCESSOR_ARCHITECTURE'] = 'foo'
import posixpath
import unittest
from posixpath import realpath, abspath, dirname, basename
-from test import support, test_genericpath
+from test import test_genericpath
+from test.support import import_helper
+from test.support import os_helper
from test.support import FakePath
from unittest import mock
# 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(support.TESTFN)
+ABSTFN = abspath(os_helper.TESTFN)
def skip_if_ABSTFN_contains_backslash(test):
"""
def tearDown(self):
for suffix in ["", "1", "2"]:
- support.unlink(support.TESTFN + suffix)
- safe_rmdir(support.TESTFN + suffix)
+ os_helper.unlink(os_helper.TESTFN + suffix)
+ safe_rmdir(os_helper.TESTFN + suffix)
def test_join(self):
self.assertEqual(posixpath.join("/foo", "bar", "/bar", "baz"),
self.assertEqual(posixpath.dirname(b"//foo//bar"), b"//foo")
def test_islink(self):
- self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
- self.assertIs(posixpath.lexists(support.TESTFN + "2"), False)
+ self.assertIs(posixpath.islink(os_helper.TESTFN + "1"), False)
+ self.assertIs(posixpath.lexists(os_helper.TESTFN + "2"), False)
- with open(support.TESTFN + "1", "wb") as f:
+ with open(os_helper.TESTFN + "1", "wb") as f:
f.write(b"foo")
- self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
+ self.assertIs(posixpath.islink(os_helper.TESTFN + "1"), False)
- if support.can_symlink():
- 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)
+ if os_helper.can_symlink():
+ os.symlink(os_helper.TESTFN + "1", os_helper.TESTFN + "2")
+ self.assertIs(posixpath.islink(os_helper.TESTFN + "2"), True)
+ os.remove(os_helper.TESTFN + "1")
+ self.assertIs(posixpath.islink(os_helper.TESTFN + "2"), True)
+ self.assertIs(posixpath.exists(os_helper.TESTFN + "2"), False)
+ self.assertIs(posixpath.lexists(os_helper.TESTFN + "2"), True)
- self.assertIs(posixpath.islink(support.TESTFN + "\udfff"), False)
- self.assertIs(posixpath.islink(os.fsencode(support.TESTFN) + b"\xff"), False)
- self.assertIs(posixpath.islink(support.TESTFN + "\x00"), False)
- self.assertIs(posixpath.islink(os.fsencode(support.TESTFN) + b"\x00"), False)
+ self.assertIs(posixpath.islink(os_helper.TESTFN + "\udfff"), False)
+ self.assertIs(posixpath.islink(os.fsencode(os_helper.TESTFN) + b"\xff"), False)
+ self.assertIs(posixpath.islink(os_helper.TESTFN + "\x00"), False)
+ self.assertIs(posixpath.islink(os.fsencode(os_helper.TESTFN) + b"\x00"), False)
def test_ismount(self):
self.assertIs(posixpath.ismount("/"), True)
self.assertIs(posixpath.ismount('/\x00'), False)
self.assertIs(posixpath.ismount(b'/\x00'), False)
- @unittest.skipUnless(support.can_symlink(),
+ @unittest.skipUnless(os_helper.can_symlink(),
"Test requires symlink support")
def test_ismount_symlinks(self):
# Symlinks are never mountpoints.
self.assertEqual(posixpath.expanduser(b"foo"), b"foo")
def test_expanduser_home_envvar(self):
- with support.EnvironmentVarGuard() as env:
+ with os_helper.EnvironmentVarGuard() as env:
env['HOME'] = '/home/victor'
self.assertEqual(posixpath.expanduser("~"), "/home/victor")
self.assertEqual(posixpath.expanduser("~/foo"), "/foo")
def test_expanduser_pwd(self):
- pwd = support.import_module('pwd')
+ pwd = import_helper.import_module('pwd')
self.assertIsInstance(posixpath.expanduser("~/"), str)
self.assertIsInstance(posixpath.expanduser(b"~/"), bytes)
self.assertIsInstance(posixpath.expanduser(b"~root/"), bytes)
self.assertIsInstance(posixpath.expanduser(b"~foo/"), bytes)
- with support.EnvironmentVarGuard() as env:
+ with os_helper.EnvironmentVarGuard() as env:
# expanduser should fall back to using the password database
del env['HOME']
os.symlink(ABSTFN+"1", ABSTFN)
self.assertEqual(realpath(ABSTFN), ABSTFN+"1")
finally:
- support.unlink(ABSTFN)
+ os_helper.unlink(ABSTFN)
@unittest.skipUnless(hasattr(os, "symlink"),
"Missing symlink implementation")
os.symlink(posixpath.relpath(ABSTFN+"1"), ABSTFN)
self.assertEqual(realpath(ABSTFN), ABSTFN+"1")
finally:
- support.unlink(ABSTFN)
+ os_helper.unlink(ABSTFN)
@unittest.skipUnless(hasattr(os, "symlink"),
"Missing symlink implementation")
self.assertEqual(realpath(ABSTFN+"c"), ABSTFN+"c")
# Test using relative path as well.
- with support.change_cwd(dirname(ABSTFN)):
+ with os_helper.change_cwd(dirname(ABSTFN)):
self.assertEqual(realpath(basename(ABSTFN)), ABSTFN)
finally:
- support.unlink(ABSTFN)
- support.unlink(ABSTFN+"1")
- support.unlink(ABSTFN+"2")
- support.unlink(ABSTFN+"y")
- support.unlink(ABSTFN+"c")
- support.unlink(ABSTFN+"a")
+ os_helper.unlink(ABSTFN)
+ os_helper.unlink(ABSTFN+"1")
+ os_helper.unlink(ABSTFN+"2")
+ os_helper.unlink(ABSTFN+"y")
+ os_helper.unlink(ABSTFN+"c")
+ os_helper.unlink(ABSTFN+"a")
@unittest.skipUnless(hasattr(os, "symlink"),
"Missing symlink implementation")
os.symlink('self/self/self', ABSTFN + '/link')
self.assertEqual(realpath(ABSTFN + '/link'), ABSTFN)
finally:
- support.unlink(ABSTFN + '/self')
- support.unlink(ABSTFN + '/link')
+ os_helper.unlink(ABSTFN + '/self')
+ os_helper.unlink(ABSTFN + '/link')
safe_rmdir(ABSTFN)
@unittest.skipUnless(hasattr(os, "symlink"),
self.assertEqual(realpath(ABSTFN + '/%d' % depth), ABSTFN)
# Test using relative path as well.
- with support.change_cwd(ABSTFN):
+ with os_helper.change_cwd(ABSTFN):
self.assertEqual(realpath('%d' % depth), ABSTFN)
finally:
for i in range(depth + 1):
- support.unlink(ABSTFN + '/%d' % i)
+ os_helper.unlink(ABSTFN + '/%d' % i)
safe_rmdir(ABSTFN)
@unittest.skipUnless(hasattr(os, "symlink"),
os.mkdir(ABSTFN + "/y")
os.symlink(ABSTFN + "/y", ABSTFN + "/k")
- with support.change_cwd(ABSTFN + "/k"):
+ with os_helper.change_cwd(ABSTFN + "/k"):
self.assertEqual(realpath("a"), ABSTFN + "/y/a")
finally:
- support.unlink(ABSTFN + "/k")
+ os_helper.unlink(ABSTFN + "/k")
safe_rmdir(ABSTFN + "/y")
safe_rmdir(ABSTFN)
# Absolute path.
self.assertEqual(realpath(ABSTFN + "/link-y/.."), ABSTFN + "/k")
# Relative path.
- with support.change_cwd(dirname(ABSTFN)):
+ with os_helper.change_cwd(dirname(ABSTFN)):
self.assertEqual(realpath(basename(ABSTFN) + "/link-y/.."),
ABSTFN + "/k")
finally:
- support.unlink(ABSTFN + "/link-y")
+ os_helper.unlink(ABSTFN + "/link-y")
safe_rmdir(ABSTFN + "/k/y")
safe_rmdir(ABSTFN + "/k")
safe_rmdir(ABSTFN)
os.mkdir(ABSTFN)
os.mkdir(ABSTFN + "/k")
os.symlink(ABSTFN, ABSTFN + "link")
- with support.change_cwd(dirname(ABSTFN)):
+ with os_helper.change_cwd(dirname(ABSTFN)):
base = basename(ABSTFN)
self.assertEqual(realpath(base + "link"), ABSTFN)
self.assertEqual(realpath(base + "link/k"), ABSTFN + "/k")
finally:
- support.unlink(ABSTFN + "link")
+ os_helper.unlink(ABSTFN + "link")
safe_rmdir(ABSTFN + "/k")
safe_rmdir(ABSTFN)
path = posixpath
def setUp(self):
- self.file_name = support.TESTFN
- self.file_path = FakePath(support.TESTFN)
- self.addCleanup(support.unlink, self.file_name)
+ self.file_name = os_helper.TESTFN
+ self.file_path = FakePath(os_helper.TESTFN)
+ self.addCleanup(os_helper.unlink, self.file_name)
with open(self.file_name, 'xb', 0) as file:
file.write(b"test_posixpath.PathLikeTests")
file.write('x = 123\n')
def tearDown(self):
- support.rmtree(self.directory)
+ os_helper.rmtree(self.directory)
def pycompilecmd(self, *args, **kwargs):
# assert_python_* helpers don't return proc object. We'll just use
# -*- coding: koi8-r -*-
import unittest
-from test.support import TESTFN, unlink, unload, rmtree, script_helper, captured_stdout
+from test.support import script_helper, captured_stdout
+from test.support.os_helper import TESTFN, unlink, rmtree
+from test.support.import_helper import unload
import importlib
import os
import sys
import unittest
from test import support
+from test.support import os_helper
import os
import platform
import sys
# we're not about to delete. If we're running under -j, that
# means the test harness provided directory isn't a safe option.
# See http://bugs.python.org/issue15526 for more details
- with support.change_cwd(path.dirname(sys.executable)):
+ with os_helper.change_cwd(path.dirname(sys.executable)):
empty = path.join(path.dirname(__file__), "empty.vbs")
startfile(empty)
startfile(empty, "open")
import platform
import sys
from test import support
+from test.support import import_helper
+from test.support import warnings_helper
import unittest
class TestUntestedModules(unittest.TestCase):
def test_untested_modules_can_be_imported(self):
untested = ('encodings', 'formatter')
- with support.check_warnings(quiet=True):
+ with warnings_helper.check_warnings(quiet=True):
for name in untested:
try:
- support.import_module('test.test_{}'.format(name))
+ import_helper.import_module('test.test_{}'.format(name))
except unittest.SkipTest:
importlib.import_module(name)
else:
import sys
import tempfile
import unittest
-from test import support
+from test.support import os_helper
if sys.platform != 'win32':
raise unittest.SkipTest("test only relevant on win32")
def test_conout_path(self):
temp_path = tempfile.mkdtemp()
- self.addCleanup(support.rmtree, temp_path)
+ self.addCleanup(os_helper.rmtree, temp_path)
conout_path = os.path.join(temp_path, 'CONOUT$')
import sys
import threading
import unittest
-from test.support import import_fresh_module
+from test.support.import_helper import import_fresh_module
OS_ENV_LOCK = threading.Lock()
TZPATH_LOCK = threading.Lock()