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_tox_testenv_interpret_shebang_real(tmpdir):
testfile = tmpdir.join("check_shebang_real.py")
base_args = [str(testfile), "arg1", "arg2", "arg3"]
# interpreter (real example)
testfile.write("#!/usr/bin/env python\n")
args = prepend_shebang_interpreter(base_args)
assert args == ["/usr/bin/env", "python"] + base_args
def test_tox_testenv_interpret_shebang_empty_interpreter_ws(tmpdir):
testfile = tmpdir.join("check_shebang_empty_interpreter_ws.py")
base_args = [str(testfile), "arg1", "arg2", "arg3"]
# empty interpreter (whitespaces)
testfile.write("#! \n")
args = prepend_shebang_interpreter(base_args)
assert args == base_args
def test_tox_testenv_interpret_shebang_long_example(tmpdir):
testfile = tmpdir.join("check_shebang_long_example.py")
base_args = [str(testfile), "arg1", "arg2", "arg3"]
# interpreter (long example)
testfile.write(
"#!this-is-an-example-of-a-very-long-interpret-directive-what-should-"
"be-directly-invoked-when-tox-needs-to-invoked-the-provided-script-"
"name-in-the-argument-list"
)
args = prepend_shebang_interpreter(base_args)
expected = [
"this-is-an-example-of-a-very-long-interpret-directive-what-should-be-"
"directly-invoked-when-tox-needs-to-invoked-the-provided-script-name-"
"in-the-argument-list"
]
assert args == expected + base_args
def test_tox_testenv_interpret_shebang_interpreter_ws(tmpdir):
testfile = tmpdir.join("check_shebang_interpreter_ws.py")
base_args = [str(testfile), "arg1", "arg2", "arg3"]
# interpreter (whitespaces)
testfile.write("#! interpreter \n\n")
args = prepend_shebang_interpreter(base_args)
assert args == ["interpreter"] + base_args
def test_tox_testenv_interpret_shebang_interpreter_arg(tmpdir):
testfile = tmpdir.join("check_shebang_interpreter_arg.py")
base_args = [str(testfile), "arg1", "arg2", "arg3"]
# interpreter with argument
testfile.write("#!interpreter argx\n")
args = prepend_shebang_interpreter(base_args)
assert args == ["interpreter", "argx"] + base_args
def test_tox_testenv_interpret_shebang_real(tmpdir):
testfile = tmpdir.join("check_shebang_real.py")
base_args = [str(testfile), "arg1", "arg2", "arg3"]
# interpreter (real example)
testfile.write("#!/usr/bin/env python\n")
args = prepend_shebang_interpreter(base_args)
assert args == ["/usr/bin/env", "python"] + base_args
def test_tox_testenv_interpret_shebang_long_example(tmpdir):
testfile = tmpdir.join("check_shebang_long_example.py")
base_args = [str(testfile), "arg1", "arg2", "arg3"]
# interpreter (long example)
testfile.write(
"#!this-is-an-example-of-a-very-long-interpret-directive-what-should-"
"be-directly-invoked-when-tox-needs-to-invoked-the-provided-script-"
"name-in-the-argument-list"
)
args = prepend_shebang_interpreter(base_args)
expected = [
"this-is-an-example-of-a-very-long-interpret-directive-what-should-be-"
"directly-invoked-when-tox-needs-to-invoked-the-provided-script-name-"
"in-the-argument-list"
]
assert args == expected + base_args
def test_tox_testenv_interpret_shebang_empty_interpreter(tmpdir):
testfile = tmpdir.join("check_shebang_empty_interpreter.py")
base_args = [str(testfile), "arg1", "arg2", "arg3"]
# empty interpreter
testfile.write("#!")
args = prepend_shebang_interpreter(base_args)
assert args == base_args
def test_tox_testenv_interpret_shebang_non_utf8(tmpdir):
testfile = tmpdir.join("check_non_utf8.py")
base_args = [str(testfile), "arg1", "arg2", "arg3"]
testfile.write_binary(b"#!\x9a\xef\x12\xaf\n")
args = prepend_shebang_interpreter(base_args)
assert args == base_args
def test_tox_testenv_interpret_shebang_interpreter_simple(tmpdir):
testfile = tmpdir.join("check_shebang_interpreter_simple.py")
base_args = [str(testfile), "arg1", "arg2", "arg3"]
# interpreter (simple)
testfile.write("#!interpreter")
args = prepend_shebang_interpreter(base_args)
assert args == ["interpreter"] + base_args