Best Python code snippet using tox_python
test_venv.py
Source:test_venv.py  
...836    testfile = tmpdir.join("check_shebang_empty_instance.py")837    base_args = [str(testfile), "arg1", "arg2", "arg3"]838    # empty instance839    testfile.write("")840    args = prepend_shebang_interpreter(base_args)841    assert args == base_args842@pytest.mark.skipif("sys.platform == 'win32'", reason="no shebang on Windows")843def test_tox_testenv_interpret_shebang_empty_interpreter(tmpdir):844    testfile = tmpdir.join("check_shebang_empty_interpreter.py")845    base_args = [str(testfile), "arg1", "arg2", "arg3"]846    # empty interpreter847    testfile.write("#!")848    args = prepend_shebang_interpreter(base_args)849    assert args == base_args850@pytest.mark.skipif("sys.platform == 'win32'", reason="no shebang on Windows")851def test_tox_testenv_interpret_shebang_empty_interpreter_ws(tmpdir):852    testfile = tmpdir.join("check_shebang_empty_interpreter_ws.py")853    base_args = [str(testfile), "arg1", "arg2", "arg3"]854    # empty interpreter (whitespaces)855    testfile.write("#!    \n")856    args = prepend_shebang_interpreter(base_args)857    assert args == base_args858@pytest.mark.skipif("sys.platform == 'win32'", reason="no shebang on Windows")859def test_tox_testenv_interpret_shebang_non_utf8(tmpdir):860    testfile = tmpdir.join("check_non_utf8.py")861    base_args = [str(testfile), "arg1", "arg2", "arg3"]862    testfile.write_binary(b"#!\x9a\xef\x12\xaf\n")863    args = prepend_shebang_interpreter(base_args)864    assert args == base_args865@pytest.mark.skipif("sys.platform == 'win32'", reason="no shebang on Windows")866def test_tox_testenv_interpret_shebang_interpreter_simple(tmpdir):867    testfile = tmpdir.join("check_shebang_interpreter_simple.py")868    base_args = [str(testfile), "arg1", "arg2", "arg3"]869    # interpreter (simple)870    testfile.write("#!interpreter")871    args = prepend_shebang_interpreter(base_args)872    assert args == ["interpreter"] + base_args873@pytest.mark.skipif("sys.platform == 'win32'", reason="no shebang on Windows")874def test_tox_testenv_interpret_shebang_interpreter_ws(tmpdir):875    testfile = tmpdir.join("check_shebang_interpreter_ws.py")876    base_args = [str(testfile), "arg1", "arg2", "arg3"]877    # interpreter (whitespaces)878    testfile.write("#!  interpreter  \n\n")879    args = prepend_shebang_interpreter(base_args)880    assert args == ["interpreter"] + base_args881@pytest.mark.skipif("sys.platform == 'win32'", reason="no shebang on Windows")882def test_tox_testenv_interpret_shebang_interpreter_arg(tmpdir):883    testfile = tmpdir.join("check_shebang_interpreter_arg.py")884    base_args = [str(testfile), "arg1", "arg2", "arg3"]885    # interpreter with argument886    testfile.write("#!interpreter argx\n")887    args = prepend_shebang_interpreter(base_args)888    assert args == ["interpreter", "argx"] + base_args889@pytest.mark.skipif("sys.platform == 'win32'", reason="no shebang on Windows")890def test_tox_testenv_interpret_shebang_interpreter_args(tmpdir):891    testfile = tmpdir.join("check_shebang_interpreter_args.py")892    base_args = [str(testfile), "arg1", "arg2", "arg3"]893    # interpreter with argument (ensure single argument)894    testfile.write("#!interpreter argx argx-part2\n")895    args = prepend_shebang_interpreter(base_args)896    assert args == ["interpreter", "argx argx-part2"] + base_args897@pytest.mark.skipif("sys.platform == 'win32'", reason="no shebang on Windows")898def test_tox_testenv_interpret_shebang_real(tmpdir):899    testfile = tmpdir.join("check_shebang_real.py")900    base_args = [str(testfile), "arg1", "arg2", "arg3"]901    # interpreter (real example)902    testfile.write("#!/usr/bin/env python\n")903    args = prepend_shebang_interpreter(base_args)904    assert args == ["/usr/bin/env", "python"] + base_args905@pytest.mark.skipif("sys.platform == 'win32'", reason="no shebang on Windows")906def test_tox_testenv_interpret_shebang_long_example(tmpdir):907    testfile = tmpdir.join("check_shebang_long_example.py")908    base_args = [str(testfile), "arg1", "arg2", "arg3"]909    # interpreter (long example)910    testfile.write(911        "#!this-is-an-example-of-a-very-long-interpret-directive-what-should-"912        "be-directly-invoked-when-tox-needs-to-invoked-the-provided-script-"913        "name-in-the-argument-list"914    )915    args = prepend_shebang_interpreter(base_args)916    expected = [917        "this-is-an-example-of-a-very-long-interpret-directive-what-should-be-"918        "directly-invoked-when-tox-needs-to-invoked-the-provided-script-name-"919        "in-the-argument-list"920    ]921    assert args == expected + base_args922@pytest.mark.parametrize("download", [True, False, None])923def test_create_download(mocksession, newconfig, download):924    config = newconfig(925        [],926        """\927        [testenv:env]928        {}929        """.format(...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
