cpython: d54ee39b061f (original) (raw)

--- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -66,6 +66,7 @@ except ImportError: from test.support.script_helper import assert_python_ok + root_in_posix = False if hasattr(os, 'geteuid'): root_in_posix = (os.geteuid() == 0) @@ -82,6 +83,23 @@ else:

Issue #14110: Some tests fail on FreeBSD if the user is in the wheel group.

HAVE_WHEEL_GROUP = sys.platform.startswith('freebsd') and os.getgid() == 0 + +@contextlib.contextmanager +def ignore_deprecation_warnings(msg_regex, quiet=False):

+ + +@contextlib.contextmanager +def bytes_filename_warn(expected):

+ +

Tests creating TESTFN

class FileTests(unittest.TestCase): def setUp(self): @@ -305,8 +323,7 @@ class StatAttributeTests(unittest.TestCa fname = self.fname.encode(sys.getfilesystemencoding()) except UnicodeEncodeError: self.skipTest("cannot encode %a for the filesystem" % self.fname)

def test_stat_result_pickle(self): @@ -443,15 +460,11 @@ class UtimeTests(unittest.TestCase): fp.write(b"ABC") def restore_float_times(state):

-

# ensure that st_atime and st_mtime are float

-

@@ -1024,8 +1037,7 @@ class BytesWalkTests(WalkTests): super().setUp() self.stack = contextlib.ExitStack() if os.name == 'nt':

def tearDown(self): self.stack.close() @@ -1580,8 +1592,7 @@ class LinkTests(unittest.TestCase): with open(file1, "w") as f1: f1.write("test")

@@ -1873,10 +1884,12 @@ class Win32ListdirTests(unittest.TestCas self.assertEqual( sorted(os.listdir(support.TESTFN)), self.created_paths) + # bytes

def test_listdir_extended_path(self): """Test when the path starts with '\\?\'.""" @@ -1886,11 +1899,13 @@ class Win32ListdirTests(unittest.TestCas self.assertEqual( sorted(os.listdir(path)), self.created_paths) + # bytes

@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") @@ -1965,9 +1980,9 @@ class Win32SymlinkTests(unittest.TestCas self.assertNotEqual(os.lstat(link), os.stat(link)) bytes_link = os.fsencode(link)

def test_12084(self): @@ -2529,36 +2544,37 @@ class Win32DeprecatedBytesAPI(unittest.T def test_deprecated(self): import nt filename = os.fsencode(support.TESTFN)

@support.skip_unless_symlink def test_symlink(self): filename = os.fsencode(support.TESTFN)

@unittest.skipUnless(hasattr(os, 'get_terminal_size'), "requires os.get_terminal_size") @@ -2696,7 +2712,8 @@ class OSErrorTests(unittest.TestCase): for filenames, func, *func_args in funcs: for name in filenames: try:

@@ -3011,7 +3028,8 @@ class TestScandir(unittest.TestCase): def test_bytes(self): if os.name == "nt": # On Windows, os.scandir(bytes) must raise an exception

self.create_file("file.txt")