Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_raise_BeforeLoadScriptNotExists_if_not_exists():
script_file = os.path.join(fixtures_dir, 'script_noexists.sh')
with pytest.raises(BeforeLoadScriptNotExists):
run_before_script(script_file)
with pytest.raises(OSError):
run_before_script(script_file)
def test_beforeload_returns_stderr_messages():
script_file = os.path.join(fixtures_dir, 'script_failed.sh')
with pytest.raises(exc.BeforeLoadScriptError) as excinfo:
run_before_script(script_file)
assert excinfo.match(r'failed with returncode')
def test_return_stdout_if_ok(capsys):
script_file = os.path.join(fixtures_dir, 'script_complete.sh')
run_before_script(script_file)
out, err = capsys.readouterr()
assert 'hello' in out
def test_raise_BeforeLoadScriptError_if_retcode():
script_file = os.path.join(fixtures_dir, 'script_failed.sh')
with pytest.raises(BeforeLoadScriptError):
run_before_script(script_file)
def test_beforeload_returncode():
script_file = os.path.join(fixtures_dir, 'script_failed.sh')
with pytest.raises(exc.BeforeLoadScriptError) as excinfo:
run_before_script(script_file)
assert excinfo.match(r'113')
assert self.server.has_session(session.name)
assert session.id
assert isinstance(session, Session)
focus = None
if 'before_script' in self.sconf:
try:
cwd = None
# we want to run the before_script file cwd'd from the
# session start directory, if it exists.
if 'start_directory' in self.sconf:
cwd = self.sconf['start_directory']
run_before_script(self.sconf['before_script'], cwd=cwd)
except Exception as e:
self.session.kill_session()
raise e
if 'options' in self.sconf:
for option, value in self.sconf['options'].items():
self.session.set_option(option, value)
if 'global_options' in self.sconf:
for option, value in self.sconf['global_options'].items():
self.session.set_option(option, value, _global=True)
if 'environment' in self.sconf:
for option, value in self.sconf['environment'].items():
self.session.set_environment(option, value)
for w, wconf in self.iter_create_windows(session):
assert isinstance(w, Window)