Commit c8e75ba2 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Disable posixpath.realpath() tests on Windows (fix for issue #6975).

parent 46764489
...@@ -9,6 +9,16 @@ from posixpath import realpath, abspath, dirname, basename ...@@ -9,6 +9,16 @@ from posixpath import realpath, abspath, dirname, basename
ABSTFN = abspath(test_support.TESTFN) ABSTFN = abspath(test_support.TESTFN)
def skip_if_ABSTFN_contains_backslash(test):
"""
On Windows, posixpath.abspath still returns paths with backslashes
instead of posix forward slashes. If this is the case, several tests
fail, so skip them.
"""
found_backslash = '\\' in ABSTFN
msg = "ABSTFN is not a posix path - tests fail"
return [test, unittest.skip(msg)(test)][found_backslash]
def safe_rmdir(dirname): def safe_rmdir(dirname):
try: try:
os.rmdir(dirname) os.rmdir(dirname)
...@@ -214,11 +224,13 @@ class PosixPathTest(unittest.TestCase): ...@@ -214,11 +224,13 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.normpath("///foo/.//bar//.//..//.//baz"), "/foo/baz") self.assertEqual(posixpath.normpath("///foo/.//bar//.//..//.//baz"), "/foo/baz")
self.assertEqual(posixpath.normpath("///..//./foo/.//bar"), "/foo/bar") self.assertEqual(posixpath.normpath("///..//./foo/.//bar"), "/foo/bar")
@skip_if_ABSTFN_contains_backslash
def test_realpath_curdir(self): def test_realpath_curdir(self):
self.assertEqual(realpath('.'), os.getcwd()) self.assertEqual(realpath('.'), os.getcwd())
self.assertEqual(realpath('./.'), os.getcwd()) self.assertEqual(realpath('./.'), os.getcwd())
self.assertEqual(realpath('/'.join(['.'] * 100)), os.getcwd()) self.assertEqual(realpath('/'.join(['.'] * 100)), os.getcwd())
@skip_if_ABSTFN_contains_backslash
def test_realpath_pardir(self): def test_realpath_pardir(self):
self.assertEqual(realpath('..'), dirname(os.getcwd())) self.assertEqual(realpath('..'), dirname(os.getcwd()))
self.assertEqual(realpath('../..'), dirname(dirname(os.getcwd()))) self.assertEqual(realpath('../..'), dirname(dirname(os.getcwd())))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment