def test_report_protocol(newconfig): config = newconfig( [], """ [testenv:mypython] deps=xy """, ) class Popen: def __init__(self, *args, **kwargs): pass def communicate(self): return "", "" def wait(self): pass session = Session(config, popen=Popen, Report=ReportExpectMock) report = session.report report.expect("using") venv = session.getvenv("mypython") venv.update() report.expect("logpopen")
def test_summary_status(self, initproj, capfd): initproj( "logexample123-0.5", filedefs={ "tests": {"test_hello.py": "def test_hello(): pass"}, "tox.ini": """ [testenv:hello] [testenv:world] """, }, ) config = parseconfig([]) session = Session(config) envs = session.venvlist assert len(envs) == 2 env1, env2 = envs env1.status = "FAIL XYZ" assert env1.status env2.status = 0 assert not env2.status session._summary() out, err = capfd.readouterr() exp = "%s: FAIL XYZ" % env1.envconfig.envname assert exp in out exp = "%s: commands succeeded" % env2.envconfig.envname assert exp in out
def test_sdist_latest(tmpdir, newconfig): distshare = tmpdir.join("distshare") config = newconfig([], """ [tox] distshare=%s sdistsrc={distshare}/pkg123-* """ % distshare) p = distshare.ensure("pkg123-1.4.5.zip") distshare.ensure("pkg123-1.4.5a1.zip") session = Session(config) sdist_path = session.get_installpkg_path() assert sdist_path == p
def test_sdist_latest(tmpdir, newconfig): distshare = tmpdir.join("distshare") config = newconfig( [], """ [tox] distshare=%s sdistsrc={distshare}/pkg123-* """ % distshare, ) p = distshare.ensure("pkg123-1.4.5.zip") distshare.ensure("pkg123-1.4.5a1.zip") session = Session(config) sdist_path = session.get_installpkg_path() assert sdist_path == p
def test_getvenv(self, initproj, capfd): 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 pytest.raises(LookupError, lambda: session.getvenv("qwe"))
def test_make_sdist_distshare(self, tmpdir, initproj): distshare = tmpdir.join("distshare") initproj("example123-0.6", filedefs={ 'tests': {'test_hello.py': "def test_hello(): pass"}, 'tox.ini': ''' [tox] distshare=%s ''' % distshare }) config = parseconfig([]) session = Session(config) sdist = session.get_installpkg_path() assert sdist.check() assert sdist.ext == ".zip" assert sdist == config.distdir.join(sdist.basename) sdist_share = config.distshare.join(sdist.basename) assert sdist_share.check() assert sdist_share.read("rb") == sdist.read("rb"), (sdist_share, sdist)
def test_getvenv(self, initproj, capfd): 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 pytest.raises(LookupError, lambda: session.getvenv("qwe"))
def test_make_sdist(self, initproj): initproj( "example123-0.5", filedefs={ "tests": {"test_hello.py": "def test_hello(): pass"}, "tox.ini": """ """, }, ) config = parseconfig([]) session = Session(config) sdist = session.get_installpkg_path() assert sdist.check() assert sdist.ext == ".zip" assert sdist == config.distdir.join(sdist.basename) sdist2 = session.get_installpkg_path() assert sdist2 == sdist sdist.write("hello") assert sdist.stat().size < 10 sdist_new = Session(config).get_installpkg_path() assert sdist_new == sdist assert sdist_new.stat().size > 10
def test_make_sdist_distshare(self, tmpdir, initproj): distshare = tmpdir.join("distshare") initproj( "example123-0.6", filedefs={ "tests": {"test_hello.py": "def test_hello(): pass"}, "tox.ini": """ [tox] distshare=%s """ % distshare, }, ) config = parseconfig([]) session = Session(config) sdist = session.get_installpkg_path() assert sdist.check() assert sdist.ext == ".zip" assert sdist == config.distdir.join(sdist.basename) sdist_share = config.distshare.join(sdist.basename) assert sdist_share.check() assert sdist_share.read("rb") == sdist.read("rb"), (sdist_share, sdist)
def test_report_protocol(newconfig): config = newconfig([], """ [testenv:mypython] deps=xy """) class Popen: def __init__(self, *args, **kwargs): pass def communicate(self): return "", "" def wait(self): pass session = Session(config, popen=Popen, Report=ReportExpectMock) report = session.report report.expect("using") venv = session.getvenv("mypython") venv.update() report.expect("logpopen")
def test_summary_status(self, initproj, capfd): initproj("logexample123-0.5", filedefs={ 'tests': {'test_hello.py': "def test_hello(): pass"}, 'tox.ini': ''' [testenv:hello] [testenv:world] ''' }) config = parseconfig([]) session = Session(config) envs = session.venvlist assert len(envs) == 2 env1, env2 = envs env1.status = "FAIL XYZ" assert env1.status env2.status = 0 assert not env2.status session._summary() out, err = capfd.readouterr() exp = "%s: FAIL XYZ" % env1.envconfig.envname assert exp in out exp = "%s: commands succeeded" % env2.envconfig.envname assert exp in out
def test_make_sdist(self, initproj): initproj("example123-0.5", filedefs={ 'tests': {'test_hello.py': "def test_hello(): pass"}, 'tox.ini': ''' ''' }) config = parseconfig([]) session = Session(config) sdist = session.get_installpkg_path() assert sdist.check() assert sdist.ext == ".zip" assert sdist == config.distdir.join(sdist.basename) sdist2 = session.get_installpkg_path() assert sdist2 == sdist sdist.write("hello") assert sdist.stat().size < 10 sdist_new = Session(config).get_installpkg_path() assert sdist_new == sdist assert sdist_new.stat().size > 10
def test_installpkg(tmpdir, newconfig): p = tmpdir.ensure("pkg123-1.0.zip") config = newconfig(["--installpkg=%s" % p], "") session = Session(config) sdist_path = session.get_installpkg_path() assert sdist_path == p