Beispiel #1
0
def test_upload(pytestconfig, pypi_chishop):
    """Test we can upload packages to an instance of chishop PyPI.
        This also covers the setuptools extensions register and upload.
    """
    with PkgTemplate(name='acme.tpi.test.upload-1.0.0.dev1') as pkg:
        pkg.create_pypirc(pypi_chishop.get_rc())
        pkg.install_package('pytest-cov')
        new_env = copy.copy(pkg.env)
        new_env['HOME'] = pkg.workspace
        setup_cmd = ['%s/setup.py' % pkg.trunk_dir]
        setup_cmd += ['sdist', 'register', 'upload', '--show-response']

        pkg.run_with_coverage(setup_cmd, pytestconfig, env=new_env, cd=HERE, capture_stdout=False)
    dist_location = ('chishop/media/dists/a/acme.tpi.test.upload'
                     '/acme.tpi.test.upload-1.0.0.dev1.tar.gz')
    assert os.path.isfile(os.path.join(pypi_chishop.workspace, dist_location))

    dist_url = ('http://%s:%s/media/dists/a/acme.tpi.test.upload'
                '/acme.tpi.test.upload-1.0.0.dev1.tar.gz'
                % (pypi_chishop.hostname, pypi_chishop.port))
    response = urlopen(dist_url)
    buf = response.read()
    fh = BytesIO(buf)
    with closing(tarfile.open(fileobj=fh)) as tf:
        assert 'acme.tpi.test.upload-1.0.0.dev1/PKG-INFO' in tf.getnames()
Beispiel #2
0
def test_upload_different_platforms(pytestconfig, pypi_chishop):
    with PkgTemplate(name='acme.tpi.test.platforms') as pkg:
        pkg.create_pypirc(pypi_chishop.get_rc())
        pkg.install_package('pytest-cov')
        setup_py = '%s/setup.py' % pkg.trunk_dir
        _add_ext_module(pkg)
        setup_cmd = [setup_py, 'bdist_egg', '-p', 'platform1', 'register', 'upload']
        pkg.run_with_coverage(setup_cmd, pytestconfig, env=dict(pkg.env, HOME=pkg.workspace),
                              cd=HERE, capture_stdout=False)

        setup_cmd = [setup_py, 'bdist_egg', '-p', 'platform2', 'register', 'upload']
        pkg.run_with_coverage(setup_cmd, pytestconfig, env=dict(pkg.env, HOME=pkg.workspace),
                              cd=HERE, capture_stdout=False)

    response = urlopen('http://%s:%s/simple/acme.tpi.test.platforms' %
                       (pypi_chishop.hostname, pypi_chishop.port))
    buf = response.read()
    pyversion = sys.version[:3]  # sysconfig.get_python_version()
    assert ('acme.tpi.test.platforms-1.0.0.dev1-py%s-platform1.egg' % pyversion) in buf
    assert ('acme.tpi.test.platforms-1.0.0.dev1-py%s-platform2.egg' % pyversion) in buf