MCPcopy Index your code
hub / github.com/datacamp/pythonwhat / ChDir

Class ChDir

pythonwhat/local.py:129–142  ·  view source on GitHub ↗

Step into a directory temporarily.

Source from the content-addressed store, hash-verified

127
128
129class ChDir(object):
130 """
131 Step into a directory temporarily.
132 """
133
134 def __init__(self, path):
135 self.old_dir = os.getcwd()
136 self.new_dir = str(path)
137
138 def __enter__(self):
139 os.chdir(self.new_dir)
140
141 def __exit__(self, *args):
142 os.chdir(self.old_dir)
143
144
145def run_code(executor, code):

Callers 8

write_fileFunction · 0.90
test_run_solution_dirFunction · 0.90
test_running_fileFunction · 0.90
in_temp_dirFunction · 0.90
run_exerciseFunction · 0.85

Calls

no outgoing calls

Tested by 6

write_fileFunction · 0.72
test_run_solution_dirFunction · 0.72
test_running_fileFunction · 0.72