From ee3e3353bf3c47b15c1afe00e378f14be47d7b60 Mon Sep 17 00:00:00 2001 From: fresheed Date: Fri, 15 Dec 2017 12:59:36 +0300 Subject: [PATCH] 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 --- fs/path.py | 2 +- tests/test_path.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/path.py b/fs/path.py index 875e536e..cf272032 100644 --- a/fs/path.py +++ b/fs/path.py @@ -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): diff --git a/tests/test_path.py b/tests/test_path.py index af39541d..6b67d2a8 100644 --- a/tests/test_path.py +++ b/tests/test_path.py @@ -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"))