Skip to content

Commit

Permalink
fix: getcwd not working as property
Browse files Browse the repository at this point in the history
  • Loading branch information
matfax committed Oct 16, 2019
1 parent dc5e3c0 commit 257a7da
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mutapath/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
__EXCLUDE_FROM_WRAPPING = ["__dir__", "__eq__", "__format__", "__repr__", "__str__", "__sizeof__", "__init__",
"__post_init__", "__getattribute__", "__delattr__", "__setattr__", "__getattr__",
"__exit__", "__fspath__", "'_Path__wrap_attribute'", "__wrap_decorator", "_op_context",
"__hash__", "__enter__", "_norm", "open", "lock"]
"__hash__", "__enter__", "_norm", "open", "lock", "getcwd"]

__MUTABLE_FUNCTIONS = {"rename", "renames", "copy", "copy2", "copyfile", "copymode", "copystat", "copytree", "move",
"basename", "abspath", "join", "joinpath", "normpath", "relpath", "realpath", "relpathto"}
Expand Down
6 changes: 6 additions & 0 deletions mutapath/immutapath.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,14 @@ def with_base(self, base, strip_length: int = 0):

@classmethod
def getcwd(cls) -> Path:
"""Get the current working directory"""
return Path(os.getcwd())

@property
def cwd(self):
"""Get the current working directory"""
return self.getcwd()

@path.multimethod
def joinpath(self, first, *others) -> Path:
contained_others = map(str, others)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_immutapath.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,7 @@ def test_lt_str(self):
lesser = Path("/A/B/")
greater = "/A/C"
self.assertLess(lesser, greater)

def test_cwd(self):
start = Path("/A/B/")
self.assertEqual(start.cwd, Path.getcwd())

0 comments on commit 257a7da

Please sign in to comment.