def test_env_override(self): old_environ = os.environ.copy() os.environ["HELLO"] = "bad" cmd = Command(["env"], env={"HELLO": "pakit"}) cmd.wait() "HELLO=pakit" in cmd.output() os.environ = old_environ
def get_hash(target): """ Required because with now forces right commit """ cmd = Command("hg identify", target) cmd.wait() return cmd.output()[0].split()[0]
def test_env_override(self): old_environ = os.environ.copy() os.environ['HELLO'] = 'bad' cmd = Command(['env'], env={'HELLO': 'pakit'}) cmd.wait() 'HELLO=pakit' in cmd.output() os.environ = old_environ
def get_hash(target): """ Required because with now forces right commit """ cmd = Command('git log -1 ', target) cmd.wait() return cmd.output()[0].split()[-1]
def test_command_dir(self): try: os.makedirs("dummy") with open("dummy/hello", "wb") as fout: fout.write("this is a sample line".encode()) cmd = Command("ls", os.path.abspath("./dummy")) cmd.wait() assert cmd.rcode == 0 assert cmd.output() == ["hello"] finally: tc.delete_it("dummy")
def test_command_dir(self): try: os.makedirs('dummy') with open('dummy/hello', 'wb') as fout: fout.write('this is a sample line'.encode()) cmd = Command('ls', os.path.abspath('./dummy')) cmd.wait() assert cmd.rcode == 0 assert cmd.output() == ['hello'] finally: tc.delete_it('dummy')
def test_prev_cmd_stdin(self): cmd = Command('echo -e "Hello\nGoodbye!"') cmd.wait() cmd2 = Command('grep "ood"', prev_cmd=cmd) cmd2.wait() assert cmd2.output() == ["Goodbye!"]
def test_output(self): cmd = Command('echo "Hello py.test"') cmd.wait() lines = cmd.output() assert lines == ["Hello py.test"]