1# Run tests for functions in Python/fileutils.c. 2 3import os 4import os.path 5import unittest 6from test.support import import_helper 7 8# Skip this test if the _testcapi module isn't available. 9_testcapi = import_helper.import_module('_testinternalcapi') 10 11 12class PathTests(unittest.TestCase): 13 14 def test_capi_normalize_path(self): 15 if os.name == 'nt': 16 raise unittest.SkipTest('Windows has its own helper for this') 17 else: 18 from test.test_posixpath import PosixPathTest as posixdata 19 tests = posixdata.NORMPATH_CASES 20 for filename, expected in tests: 21 if not os.path.isabs(filename): 22 continue 23 with self.subTest(filename): 24 result = _testcapi.normalize_path(filename) 25 self.assertEqual(result, expected, 26 msg=f'input: {filename!r} expected output: {expected!r}') 27 28 29if __name__ == "__main__": 30 unittest.main() 31