test_fileutils.py 951 B

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