Beispiel #1
0
def test_process_package_tox_succeeded_bdist(tmpdir, monkeypatch):
    py = "py{}{}".format(*sys.version_info[:2])
    url = "http://plugincompat.example.com/output/myplugin-1.0.0?py={}&pytest=3.7.4".format(
        py)
    responses.add(responses.GET, url, status=404)
    monkeypatch.setattr(
        "run.download_package",
        lambda client, name, version: "myplugin-1.0.0-py2.py3-none-any.whl")
    here = os.path.dirname(__file__)
    canned_whl = os.path.join(here, 'test_data',
                              'myplugin-1.0.0-py2.py3-none-any.whl')
    copy(canned_whl, str(tmpdir))
    monkeypatch.chdir(tmpdir)
    result = process_package(
        tox_env=py,
        pytest_version="3.7.4",
        name="myplugin",
        version="1.0.0",
        description="nope",
    )
    assert result.name == "myplugin"
    assert result.version == "1.0.0"
    assert result.status_code == 0
    assert result.status == "PASSED"
    assert result.description == "nope"
    assert result.elapsed == 0.0
    assert "hi from tox" not in result.output
    assert "hello world from .whl pytest plugin" in result.output
    assert "PLUGIN registered: <module 'myplugin'" in result.output
    assert "congratulations :)" in result.output
Beispiel #2
0
def test_process_package_tox_succeeded_bdist(tmpdir, monkeypatch):
    py = "py{}{}".format(*sys.version_info[:2])
    url = "http://plugincompat.example.com/output/myplugin-1.0.0?py={}&pytest=3.7.4".format(
        py
    )
    responses.add(responses.GET, url, status=404)
    monkeypatch.setattr(
        "run.download_package", lambda client, name, version: "myplugin-1.0.0-py2.py3-none-any.whl"
    )
    here = os.path.dirname(__file__)
    canned_whl = os.path.join(here, 'test_data', 'myplugin-1.0.0-py2.py3-none-any.whl')
    copy(canned_whl, str(tmpdir))
    monkeypatch.chdir(tmpdir)
    result = process_package(
        tox_env=py,
        pytest_version="3.7.4",
        name="myplugin",
        version="1.0.0",
        description="nope",
    )
    assert result.name == "myplugin"
    assert result.version == "1.0.0"
    assert result.status_code == 0
    assert result.status == "PASSED"
    assert result.description == "nope"
    assert result.elapsed == 0.0
    assert "hi from tox" not in result.output
    assert "hello world from .whl pytest plugin" in result.output
    assert "PLUGIN registered: <module 'myplugin'" in result.output
    assert "congratulations :)" in result.output
Beispiel #3
0
def test_process_package_tox_succeeded(tmpdir, monkeypatch):
    py = "py{}{}".format(*sys.version_info[:2])
    url = "http://plugincompat.example.com/output/myplugin-1.0?py={}&pytest=3.7.4".format(
        py)
    responses.add(responses.GET, url, status=404)
    monkeypatch.setattr("run.download_package",
                        lambda client, name, version: "myplugin.zip")
    monkeypatch.chdir(tmpdir)
    tmpdir.join("myplugin").ensure_dir()
    tmpdir.join("myplugin").join("setup.py").write(
        "from distutils.core import setup\nsetup(name='myplugin', version='1.0')"
    )
    tmpdir.join("myplugin").join("tox.ini").write(canned_tox_ini)
    with zipfile.ZipFile(str(tmpdir / "myplugin.zip"), mode="w") as z:
        z.write("myplugin")
    result = process_package(
        tox_env=py,
        pytest_version="3.7.4",
        name="myplugin",
        version="1.0",
        description="'sup",
    )
    assert result.name == "myplugin"
    assert result.version == "1.0"
    assert result.status_code == 0
    assert result.status == "PASSED"
    assert result.description == "'sup"
    assert result.elapsed == 0.0
    assert "hi from tox" in result.output
    assert "congratulations :)" in result.output
Beispiel #4
0
def test_process_package_tox_succeeded(tmpdir, monkeypatch):
    py = "py{}{}".format(*sys.version_info[:2])
    url = "http://plugincompat.example.com/output/myplugin-1.0?py={}&pytest=3.7.4".format(
        py
    )
    responses.add(responses.GET, url, status=404)
    monkeypatch.setattr(
        "run.download_package", lambda client, name, version: "myplugin.zip"
    )
    monkeypatch.chdir(tmpdir)
    tmpdir.join("myplugin").ensure_dir()
    tmpdir.join("myplugin").join("setup.py").write(
        "from distutils.core import setup\nsetup(name='myplugin', version='1.0')"
    )
    tmpdir.join("myplugin").join("tox.ini").write(canned_tox_ini)
    with zipfile.ZipFile(str(tmpdir/"myplugin.zip"), mode="w") as z:
        z.write("myplugin")
    result = process_package(
        tox_env=py,
        pytest_version="3.7.4",
        name="myplugin",
        version="1.0",
        description="'sup",
    )
    assert result.name == "myplugin"
    assert result.version == "1.0"
    assert result.status_code == 0
    assert result.status == "PASSED"
    assert result.description == "'sup"
    assert result.elapsed == 0.0
    assert "hi from tox" in result.output
    assert "congratulations :)" in result.output
Beispiel #5
0
def test_process_package_skips_if_result_already_on_plugincompat_website():
    url = "http://plugincompat.example.com/output/myplugin-1.0?py=py10&pytest=1.2.3"
    responses.add(responses.GET, url)
    result = process_package(
        tox_env="py10",
        pytest_version="1.2.3",
        name="myplugin",
        version="1.0",
        description="'sup",
    )
    assert result == PackageResult(
        name="myplugin",
        version="1.0",
        status_code=0,
        status="SKIPPED",
        output="Skipped",
        description="'sup",
        elapsed=0.0,
    )
Beispiel #6
0
def test_process_package_skips_if_result_already_on_plugincompat_website():
    url = "http://plugincompat.example.com/output/myplugin-1.0?py=py10&pytest=1.2.3"
    responses.add(responses.GET, url)
    result = process_package(
        tox_env="py10",
        pytest_version="1.2.3",
        name="myplugin",
        version="1.0",
        description="'sup",
    )
    assert result == PackageResult(
        name="myplugin",
        version="1.0",
        status_code=0,
        status="SKIPPED",
        output="Skipped",
        description="'sup",
        elapsed=0.0,
    )
Beispiel #7
0
def test_process_package_tox_crash(tmpdir, monkeypatch):
    url = "http://plugincompat.example.com/output/myplugin-1.0?py=py36&pytest=1.2.3"
    responses.add(responses.GET, url, status=404)
    monkeypatch.setattr("run.download_package",
                        lambda client, name, version: "myplugin.zip")
    monkeypatch.chdir(tmpdir)
    empty_zipfile_bytes = b"PK\x05\x06" + b"\x00" * 18
    tmpdir.join("myplugin.zip").write(empty_zipfile_bytes)
    result = process_package(
        tox_env="py36",
        pytest_version="1.2.3",
        name="myplugin",
        version="1.0",
        description="'sup",
    )
    assert result.name == "myplugin"
    assert result.status_code == 1
    assert result.status == "FAILED"
    assert result.output.startswith("traceback:\n")
    assert "No such file or directory: 'myplugin/tox.ini'" in result.output
Beispiel #8
0
def test_process_package_no_dist_available(monkeypatch):
    url = "http://plugincompat.example.com/output/myplugin-1.0?py=py10&pytest=1.2.3"
    responses.add(responses.GET, url, status=404)
    monkeypatch.setattr("run.download_package", lambda client, name, version: None)
    result = process_package(
        tox_env="py10",
        pytest_version="1.2.3",
        name="myplugin",
        version="1.0",
        description="'sup",
    )
    assert result == PackageResult(
        name="myplugin",
        version="1.0",
        status_code=1,
        status="NO DIST",
        output="No source or compatible distribution found",
        description="'sup",
        elapsed=0.0,
    )
Beispiel #9
0
def test_process_package_tox_errored(tmpdir, monkeypatch):
    url = "http://plugincompat.example.com/output/myplugin-1.0?py=py36&pytest=1.2.3"
    responses.add(responses.GET, url, status=404)
    monkeypatch.setattr("run.download_package",
                        lambda client, name, version: "myplugin.zip")
    monkeypatch.chdir(tmpdir)
    tmpdir.join("myplugin").ensure_dir()
    tmpdir.join("myplugin").join("setup.py").ensure(file=True)
    with zipfile.ZipFile(str(tmpdir / "myplugin.zip"), mode="w") as z:
        z.write("myplugin")
    result = process_package(
        tox_env="py36",
        pytest_version="1.2.3",
        name="myplugin",
        version="1.0",
        description="'sup",
    )
    assert result.name == "myplugin"
    assert result.status_code == 1
    assert result.status == "FAILED"
    assert "ERROR: setup.py is empty" in result.output
Beispiel #10
0
def test_process_package_no_dist_available(monkeypatch):
    url = "http://plugincompat.example.com/output/myplugin-1.0?py=py10&pytest=1.2.3"
    responses.add(responses.GET, url, status=404)
    monkeypatch.setattr("run.download_package",
                        lambda client, name, version: None)
    result = process_package(
        tox_env="py10",
        pytest_version="1.2.3",
        name="myplugin",
        version="1.0",
        description="'sup",
    )
    assert result == PackageResult(
        name="myplugin",
        version="1.0",
        status_code=1,
        status="NO DIST",
        output="No source or compatible distribution found",
        description="'sup",
        elapsed=0.0,
    )
Beispiel #11
0
def test_process_package_tox_crash(tmpdir, monkeypatch):
    url = "http://plugincompat.example.com/output/myplugin-1.0?py=py36&pytest=1.2.3"
    responses.add(responses.GET, url, status=404)
    monkeypatch.setattr(
        "run.download_package", lambda client, name, version: "myplugin.zip"
    )
    monkeypatch.chdir(tmpdir)
    empty_zipfile_bytes = b"PK\x05\x06" + b"\x00" * 18
    tmpdir.join("myplugin.zip").write(empty_zipfile_bytes)
    result = process_package(
        tox_env="py36",
        pytest_version="1.2.3",
        name="myplugin",
        version="1.0",
        description="'sup",
    )
    assert result.name == "myplugin"
    assert result.status_code == 1
    assert result.status == "FAILED"
    assert result.output.startswith("traceback:\n")
    fn = os.path.join("myplugin", "tox.ini")
    assert "No such file or directory: {fn!r}".format(fn=fn) in result.output
Beispiel #12
0
def test_process_package_tox_errored(tmpdir, monkeypatch):
    url = "http://plugincompat.example.com/output/myplugin-1.0?py=py36&pytest=1.2.3"
    responses.add(responses.GET, url, status=404)
    monkeypatch.setattr(
        "run.download_package", lambda client, name, version: "myplugin.zip"
    )
    monkeypatch.chdir(tmpdir)
    tmpdir.join("myplugin").ensure_dir()
    tmpdir.join("myplugin").join("setup.py").ensure(file=True)
    with zipfile.ZipFile(str(tmpdir/"myplugin.zip"), mode="w") as z:
        z.write("myplugin")
    result = process_package(
        tox_env="py36",
        pytest_version="1.2.3",
        name="myplugin",
        version="1.0",
        description="'sup",
    )
    assert result.name == "myplugin"
    assert result.status_code == 1
    assert result.status == "FAILED"
    assert "ERROR: setup.py is empty" in result.output