Skip to content

Commit ee3e335

Browse files
fresheedwillmcgugan
authored andcommitted
Fixed isbase method (#117)
* Fixed isbase method Child and parent pathes were swapped by mistake * Updated tests to comply documentation isbase test case contradicted docs: first argument was child, second was parent, which is incorrect
1 parent 7e5d556 commit ee3e335

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

fs/path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def isbase(path1, path2):
437437
"""
438438
_path1 = forcedir(abspath(path1))
439439
_path2 = forcedir(abspath(path2))
440-
return _path1.startswith(_path2)
440+
return _path2.startswith(_path1) # longer one is child
441441

442442

443443
def isparent(path1, path2):

tests/test_path.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def test_recursepath(self):
146146
self.assertEquals(recursepath("", reverse=True), ["/"])
147147

148148
def test_isbase(self):
149-
self.assertTrue(isbase('foo/bar', 'foo'))
150-
self.assertFalse(isbase('foo/bar', 'baz'))
149+
self.assertTrue(isbase('foo', 'foo/bar'))
150+
self.assertFalse(isbase('baz', 'foo/bar'))
151151

152152
def test_isparent(self):
153153
self.assertTrue(isparent("foo/bar", "foo/bar/spam.txt"))

0 commit comments

Comments
 (0)