How to use the tox.session.Session function in tox

To help you get started, we’ve selected a few tox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tox-dev / tox / tests / unit / package / test_package.py View on Github external
def test_sdist_latest(tmpdir, newconfig):
    distshare = tmpdir.join("distshare")
    config = newconfig(
        [],
        """
            [tox]
            distshare={}
            sdistsrc={{distshare}}/pkg123-*
    """.format(
            distshare
        ),
    )
    p = distshare.ensure("pkg123-1.4.5.zip")
    distshare.ensure("pkg123-1.4.5a1.zip")
    session = Session(config)
    _, dist = get_package(session)
    assert dist == p
github tox-dev / tox-venv / tests / test_z_cmdline.py View on Github external
def test_getvenv(self, initproj):
        initproj(
            "logexample123-0.5",
            filedefs={
                "tests": {"test_hello.py": "def test_hello(): pass"},
                "tox.ini": """
            [testenv:hello]
            [testenv:world]
            """,
            },
        )
        config = parseconfig([])
        session = Session(config)
        venv1 = session.getvenv("hello")
        venv2 = session.getvenv("hello")
        assert venv1 is venv2
        venv1 = session.getvenv("world")
        venv2 = session.getvenv("world")
        assert venv1 is venv2
        with pytest.raises(LookupError):
            session.getvenv("qwe")
github tox-dev / tox / tests / unit / test_package.py View on Github external
"tests": {"test_hello.py": "def test_hello(): pass"},
            "tox.ini": """
        """,
        },
    )
    config = parseconfig([])
    session = Session(config)
    _, sdist = get_package(session)
    assert sdist.check()
    assert sdist.ext == ".zip"
    assert sdist == config.distdir.join(sdist.basename)
    _, sdist2 = get_package(session)
    assert sdist2 == sdist
    sdist.write("hello")
    assert sdist.stat().size < 10
    _, sdist_new = get_package(Session(config))
    assert sdist_new == sdist
    assert sdist_new.stat().size > 10
github tox-dev / tox / src / tox / _pytestplugin.py View on Github external
def build_session(config):
        session = tox.session.Session(config, popen=popen)
        res[id(session)] = Result(session)
        return session
github tox-dev / tox / src / tox / _pytestplugin.py View on Github external
def create_mocksession(request):
    config = request.getfixturevalue("newconfig")([], "")

    class MockSession(tox.session.Session):
        def __init__(self, config):
            self.logging_levels(config.option.quiet_level, config.option.verbose_level)
            super(MockSession, self).__init__(config, popen=self.popen)
            self._pcalls = []
            self.report = ReportExpectMock()

        def _clearmocks(self):
            if not six.PY2:
                self._pcalls.clear()
            else:
                del self._pcalls[:]
            self.report.clear()

        def popen(self, args, cwd, shell=None, stdout=None, stderr=None, env=None, **_):
            process_call_mock = pcallMock(args, cwd, env, stdout, stderr, shell)
            self._pcalls.append(process_call_mock)
github tox-dev / tox / tests / unit / test_package.py View on Github external
def test_make_sdist(initproj):
    initproj(
        "example123-0.5",
        filedefs={
            "tests": {"test_hello.py": "def test_hello(): pass"},
            "tox.ini": """
        """,
        },
    )
    config = parseconfig([])
    session = Session(config)
    _, sdist = get_package(session)
    assert sdist.check()
    assert sdist.ext == ".zip"
    assert sdist == config.distdir.join(sdist.basename)
    _, sdist2 = get_package(session)
    assert sdist2 == sdist
    sdist.write("hello")
    assert sdist.stat().size < 10
    _, sdist_new = get_package(Session(config))
    assert sdist_new == sdist
    assert sdist_new.stat().size > 10
github tox-dev / tox / tox / session.py View on Github external
def main(args=None):
    try:
        config = prepare(args)
        retcode = Session(config).runcommand()
        raise SystemExit(retcode)
    except KeyboardInterrupt:
        raise SystemExit(2)
    except tox.exception.MinVersionError as e:
        r = Reporter(None)
        r.error(e.message)
        raise SystemExit(1)
github tonybaloney / retox / retox / service.py View on Github external
def toxsession(self):
        try:
            return self._toxsession
        except AttributeError:
            self._logger.debug('Starting new session')
            self._toxsession = tox.session.Session(
                self._toxconfig, Report=RetoxReporter, popen=Popen)
            return self._toxsession