Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Commit

Permalink
#41: Improve basic test case by doing backup of environment and cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Oct 23, 2020
1 parent 0d92926 commit 989c082
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/rkd/api/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def setUp(self) -> None:
def tearDown(self) -> None:
self._restore_standard_out()

super().setUp()
super().tearDown()

def _restore_standard_out(self):
if not self._stderr or not self._stderr:
Expand All @@ -57,6 +57,21 @@ def _restore_standard_out(self):


class BasicTestingCase(TestCase):
_envs = None
_cwd = None

def setUp(self) -> None:
self._envs = deepcopy(os.environ)
self._cwd = os.getcwd()

super().setUp()

def tearDown(self) -> None:
os.environ = self._envs
os.chdir(self._cwd)

super().tearDown()

@contextmanager
def environment(self, environ: dict):
"""
Expand Down

0 comments on commit 989c082

Please sign in to comment.