MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / mock_program_with_code

Method mock_program_with_code

tests/utils/mock.py:31–44  ·  view source on GitHub ↗
(self, name: str, code: str)

Source from the content-addressed store, hash-verified

29
30 @contextlib.contextmanager
31 def mock_program_with_code(self, name: str, code: str):
32 import textwrap
33
34 content = f"#!{sys.executable}\n{textwrap.dedent(code)}"
35 program_path = self.directory / name
36 assert not program_path.is_file()
37
38 with open(program_path, "w") as f:
39 f.write(content)
40 os.chmod(program_path, 0o700)
41
42 yield program_path
43
44 os.unlink(program_path)

Callers 10

test_deploy_ssh_errorFunction · 0.80
bodyFunction · 0.80
test_manager_autodetectFunction · 0.80
test_manager_pbsFunction · 0.80
test_manager_slurmFunction · 0.80

Calls

no outgoing calls

Tested by 10

test_deploy_ssh_errorFunction · 0.64
bodyFunction · 0.64
test_manager_autodetectFunction · 0.64
test_manager_pbsFunction · 0.64
test_manager_slurmFunction · 0.64