Skip to content

Commit

Permalink
Fixed isbase method (#117)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
fresheed authored and willmcgugan committed Dec 15, 2017
1 parent 7e5d556 commit ee3e335
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fs/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def isbase(path1, path2):
"""
_path1 = forcedir(abspath(path1))
_path2 = forcedir(abspath(path2))
return _path1.startswith(_path2)
return _path2.startswith(_path1) # longer one is child


def isparent(path1, path2):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def test_recursepath(self):
self.assertEquals(recursepath("", reverse=True), ["/"])

def test_isbase(self):
self.assertTrue(isbase('foo/bar', 'foo'))
self.assertFalse(isbase('foo/bar', 'baz'))
self.assertTrue(isbase('foo', 'foo/bar'))
self.assertFalse(isbase('baz', 'foo/bar'))

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

0 comments on commit ee3e335

Please sign in to comment.