Skip to content

Commit

Permalink
Add tests for pushd. Increases coverage from 66% to 71%.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jan 18, 2023
1 parent 7b16fd4 commit 7e22446
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v4.2.1
======

Added test for ``pushd``.

v4.2.0
======

Expand Down
7 changes: 7 additions & 0 deletions jaraco/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@

@contextlib.contextmanager
def pushd(dir):
"""
>>> tmp_path = getfixture('tmp_path')
>>> with pushd(tmp_path):
... assert os.getcwd() == os.fspath(tmp_path)
>>> assert os.getcwd() != os.fspath(tmp_path)
"""

orig = os.getcwd()
os.chdir(dir)
try:
Expand Down

0 comments on commit 7e22446

Please sign in to comment.