def test_tox_envlist_unknown(capsys, toxinidir: PathPlus, os_sep): # The output varies depending on the versions of python installed on the host try: run_tox(["-n", "cov"], toxinidir) finally: capout = capsys.readouterr() assert "tox: error: Unknown envlist 'cov'. (envlists are 'test' and 'qa')" in capout.err
def test_no_hook(basic_docs_testenv, tmp_pathplus, capsys): try: run_tox(["-e", "docs", "-r"], tmp_pathplus) finally: stdout = capsys.readouterr().out print(stdout) assert "docs recreate hook: " not in stdout
def test_tox_envlist_test(capsys, toxinidir: PathPlus, os_sep): # The output varies depending on the versions of python installed on the host try: run_tox(["-n", "test"], toxinidir) finally: capout = capsys.readouterr() assert not capout.err assert capout.out
def test_simple_custom_hook(basic_docs_testenv, tmp_pathplus, capsys): with (tmp_pathplus / "tox.ini").open('a') as fp: fp.write('recreate_hook = "hello world"') try: run_tox(["-e", "docs", "-r"], tmp_pathplus) finally: stdout = capsys.readouterr().out print(stdout) assert f"docs recreate hook: hello world" in stdout
def test_tox_envlist_no_command(capsys, toxinidir: PathPlus, os_sep): # The output varies depending on the versions of python installed on the host tox.reporter._INSTANCE.tw._file = sys.stdout try: run_tox([], toxinidir) finally: capout = capsys.readouterr() assert not capout.err assert capout.out
def test_rmdir_docs(basic_docs_testenv, tmp_pathplus, capsys): with (tmp_pathplus / "tox.ini").open('a') as fp: fp.write( 'recreate_hook = builtin.rmdir(r"{toxinidir}/doc-source/build")\n') try: run_tox(["-e", "docs", "-r"], tmp_pathplus) finally: stdout = capsys.readouterr().out print(stdout) assert (tmp_pathplus / "doc-source").is_dir() assert not basic_docs_testenv.is_dir() assert f"docs recreate hook: removing {basic_docs_testenv}" in stdout
def test_custom_hook(basic_docs_testenv, tmp_pathplus, capsys): with (tmp_pathplus / "tox.ini").open('a') as fp: fp.write('recreate_hook = custom_hook.custom_hook()\n') (tmp_pathplus / "custom_hook.py").write_lines([ "def custom_hook() -> str:", '\treturn "this is a custom hook"', ]) try: run_tox(["-e", "docs", "-r"], tmp_pathplus) finally: stdout = capsys.readouterr().out print(stdout) assert f"docs recreate hook: this is a custom hook" in stdout
def test_tox_envlist( capsys, command: List[str], toxinidir: PathPlus, version: str, os_sep, advanced_file_regression: AdvancedFileRegressionFixture, ): try: run_tox(command, toxinidir) finally: capout = capsys.readouterr() assert not capout.err advanced_file_regression.check(prepare_stdout(capout.out, toxinidir))
def test_rmdir_mypy(tmp_pathplus, capsys): cache_dir = tmp_pathplus / ".mypy_cache" cache_dir.mkdir() (tmp_pathplus / "tox.ini").write_lines([ "[testenv:mypy]", "deps = mypy", "skip_install = True", "commands = mypy --version", 'recreate_hook = builtin.rmdir(r"{toxinidir}/.mypy_cache")', ]) try: run_tox(["-e", "mypy", "-r"], tmp_pathplus) finally: stdout = capsys.readouterr().out print(stdout) assert not cache_dir.is_dir() assert f"mypy recreate hook: removing {cache_dir}" in stdout