How to use tox_package method in tox

Best Python code snippet using tox_python

test_package.py

Source:test_package.py Github

copy

Full Screen

1import re2import sys3from tox.config import parseconfig4from tox.package import get_package5from tox.session import Session6def test_install_via_installpkg(mock_venv, initproj, cmd):7 base = initproj(8 "pkg-0.1",9 filedefs={10 "tox.ini": """11 [tox]12 install_cmd = python -m -c 'print("ok")' -- {opts} {packages}'13 """,14 },15 )16 fake_package = base.ensure(".tox", "dist", "pkg123-0.1.zip")17 result = cmd("-e", "py", "--notest", "--installpkg", str(fake_package.relto(base)))18 result.assert_success()19def test_installpkg(tmpdir, newconfig):20 p = tmpdir.ensure("pkg123-1.0.zip")21 config = newconfig(["--installpkg={}".format(p)], "")22 session = Session(config)23 _, sdist_path = get_package(session)24 assert sdist_path == p25def test_sdist_latest(tmpdir, newconfig):26 distshare = tmpdir.join("distshare")27 config = newconfig(28 [],29 """30 [tox]31 distshare={}32 sdistsrc={{distshare}}/pkg123-*33 """.format(34 distshare,35 ),36 )37 p = distshare.ensure("pkg123-1.4.5.zip")38 distshare.ensure("pkg123-1.4.5a1.zip")39 session = Session(config)40 _, dist = get_package(session)41 assert dist == p42def test_separate_sdist_no_sdistfile(cmd, initproj, tmpdir):43 distshare = tmpdir.join("distshare")44 initproj(45 ("pkg123-foo", "0.7"),46 filedefs={47 "tox.ini": """48 [tox]49 distshare={}50 """.format(51 distshare,52 ),53 },54 )55 result = cmd("--sdistonly", "-e", "py")56 assert not result.ret57 distshare_files = distshare.listdir()58 assert len(distshare_files) == 159 sdistfile = distshare_files[0]60 assert "pkg123-foo-0.7.zip" in str(sdistfile)61def test_sdistonly(initproj, cmd):62 initproj(63 "example123",64 filedefs={65 "tox.ini": """66 """,67 },68 )69 result = cmd("-v", "--sdistonly", "-e", "py")70 assert not result.ret71 assert re.match(r".*sdist-make.*setup.py.*", result.out, re.DOTALL)72 assert "-mvirtualenv" not in result.out73def test_make_sdist(initproj):74 initproj(75 "example123-0.5",76 filedefs={77 "tests": {"test_hello.py": "def test_hello(): pass"},78 "tox.ini": """79 """,80 },81 )82 config = parseconfig([])83 session = Session(config)84 _, sdist = get_package(session)85 assert sdist.check()86 assert sdist.ext == ".zip"87 assert sdist == config.distdir.join(sdist.basename)88 _, sdist2 = get_package(session)89 assert sdist2 == sdist90 sdist.write("hello")91 assert sdist.stat().size < 1092 _, sdist_new = get_package(Session(config))93 assert sdist_new == sdist94 assert sdist_new.stat().size > 1095def test_build_backend_without_submodule(initproj, cmd):96 # The important part of this test is that the build backend97 # "inline_backend" is just a base package without a submodule.98 # (Regression test for #1344)99 initproj(100 "magic-0.1",101 filedefs={102 "tox.ini": """\103 [tox]104 isolated_build = true105 [testenv:.package]106 basepython = {}107 [testenv]108 setenv = PYTHONPATH = {{toxinidir}}109 """.format(110 sys.executable,111 ),112 "pyproject.toml": """\113 [build-system]114 requires = []115 build-backend = "inline_backend"116 """,117 # To trigger original bug, must be package with __init__.py118 "inline_backend": {119 "__init__.py": """\120 def get_requires_for_build_sdist(*args, **kwargs):121 return ["pathlib2"]122 def build_sdist(sdist_directory, config_settings=None):123 import pathlib2124 (pathlib2.Path(sdist_directory) / "magic-0.1.0.tar.gz").touch()125 return "magic-0.1.0.tar.gz"126 """,127 },128 ".gitignore": ".tox",129 },130 add_missing_setup_py=False,131 )132 result = cmd("--sdistonly", "-e", "py", "-v", "-v")133 result.assert_success(is_run_test_env=False)134def test_package_inject(initproj, cmd, monkeypatch, tmp_path):135 monkeypatch.delenv(str("PYTHONPATH"), raising=False)136 initproj(137 "example123-0.5",138 filedefs={139 "tox.ini": """140 [testenv:py]141 passenv = PYTHONPATH142 commands = python -c 'import os; assert os.path.exists(os.environ["TOX_PACKAGE"])'143 """,144 },145 )146 result = cmd("-q")...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tox automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful