Commit f03463f0 by willmcgugan

Fixed bug with normpath('.') and added test

parent d52cc3fb
...@@ -12,7 +12,7 @@ optional leading slash). ...@@ -12,7 +12,7 @@ optional leading slash).
import re import re
_requires_normalization = re.compile(r'/\.\.|\./|//|\\').search _requires_normalization = re.compile(r'/\.\.|\./|\.|//|\\').search
def normpath(path): def normpath(path):
"""Normalizes a path to be in the format expected by FS objects. """Normalizes a path to be in the format expected by FS objects.
...@@ -40,7 +40,7 @@ def normpath(path): ...@@ -40,7 +40,7 @@ def normpath(path):
if path in ('', '/'): if path in ('', '/'):
return path return path
# An early out if there is no need to normalize this paath # An early out if there is no need to normalize this path
if not _requires_normalization(path): if not _requires_normalization(path):
return path.rstrip('/') return path.rstrip('/')
......
...@@ -15,6 +15,8 @@ class TestPathFunctions(unittest.TestCase): ...@@ -15,6 +15,8 @@ class TestPathFunctions(unittest.TestCase):
def test_normpath(self): def test_normpath(self):
tests = [ ("\\a\\b\\c", "/a/b/c"), tests = [ ("\\a\\b\\c", "/a/b/c"),
(".", ""),
("./", ""),
("", ""), ("", ""),
("/a/b/c", "/a/b/c"), ("/a/b/c", "/a/b/c"),
("a/b/c", "a/b/c"), ("a/b/c", "a/b/c"),
......
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