def test_source(tmpdir): """Test that sourcing a shell file loads it.""" script = tmpdir.join('test.sh') script.write('#!/bin/bash\n\necho AAAAAA\n' 'export TEST_ANOTHER=test\ntouch /tmp/blah') with bash(source=['test.sh'], pwd=tmpdir.strpath) as s: assert s.envvars['TEST_ANOTHER'] == 'test'
def test_script_return_code(tmpdir): script = tmpdir.join('test.sh') script.write('#!/bin/env bash\n\nblahcommand\n') script.chmod(0o777) with bash() as s: s.auto_return_code_error = False out = s.run_script(script) assert s.last_return_code == 126
def test_basic_command(testdir): with bash() as s: s.send('ls /')
def test_env_var(testdir): """Test setting an environment variable.""" with bash() as s: s.set_env('TEST_VARIABLE', 'blahBLAH') assert s.envvars['TEST_VARIABLE'] == 'blahBLAH'
def bash_fixture(request): from pytest_shell.shell import bash with bash() as b: yield b