Skip to content

Commit

Permalink
adding chdir method to base test
Browse files Browse the repository at this point in the history
rpmcginty committed Dec 23, 2023
1 parent 7926635 commit f07adb9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/aibs_informatics_test_resources/base.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import re
import tempfile
import unittest
from contextlib import contextmanager
from contextlib import nullcontext as does_not_raise
from copy import deepcopy
from pathlib import Path
@@ -83,3 +84,12 @@ def create_patch(self, name: str, **kwargs) -> MagicMock:
self.addCleanup(patcher.stop)
thing = patcher.start()
return thing

@contextmanager
def chdir(self, destination: Union[str, Path]):
current_dir = os.getcwd()
try:
os.chdir(destination)
yield
finally:
os.chdir(current_dir)

0 comments on commit f07adb9

Please sign in to comment.