from subprocess import STDOUT from autonomic.utils import is_proc, run, yaml_dump, yaml_load def test_run_kwargs(): assert run(["whoami"], stderr=STDOUT) is not None def test_run_cwd(tmp_path): directory = tmp_path / "test" directory.mkdir() testfile = directory / "testfile.txt" testfile.write_text("hello, world") output = run(["ls"], cwd=directory.absolute()) assert "testfile.txt" in output def test_yaml_load(tmp_path): directory = tmp_path / "test" directory.mkdir() testfile = directory / "testfile.yml" testfile.write_text("---\nusername: foobar") loaded = yaml_load(testfile.absolute()) assert loaded["username"] == "foobar" def test_yaml_dump(tmp_path): directory = tmp_path / "test" directory.mkdir() testfile = directory / "testfile.yml" yaml_dump(testfile.absolute(), {"username": "foobar"}) loaded = yaml_load(testfile.absolute()) assert loaded["username"] == "foobar" def test_is_proc(): assert is_proc("pytest") is True