FIX test_server FC!

+ Generate dummy-dists within tests to support running on every 
  platform/py-version.
  + delete pr-generated dummy-wheels.
+ Add forgotten test-packages `twinw`, `passlib`!
+ Update bugfix signing `twine` 1.6.1-->1.6.1.
This commit is contained in:
ankostis on tokoti 2015-09-19 02:36:43 +02:00 committed by Kostis Anagnostopoulos at kilo
parent e044b8e74e
commit 3676771719
9 changed files with 92 additions and 66 deletions

1
.gitignore vendored
View File

@ -32,4 +32,5 @@ __pycache__/
/develop-eggs/ /develop-eggs/
/eggs/ /eggs/
/parts/ /parts/
/.cache/
/.settings/ /.settings/

View File

@ -12,7 +12,9 @@ pip install --extra-index-url {{URL}}simple/ PACKAGE [PACKAGE2...]
easy_install -i {{URL}}simple/ PACKAGE easy_install -i {{URL}}simple/ PACKAGE
</pre></blockquote></p> </pre></blockquote></p>
<p>The complete list of all packages can be found <a href="{{PACKAGES}}">here</a> or via the <a href="{{SIMPLE}}">simple</a> index.</p> <p>The complete list of all packages can be found <a href="{{PACKAGES}}">here</a>
or via the <a href="{{SIMPLE}}">simple</a> index.</p>
<p>This instance is running version {{VERSION}} of the <a href="http://pypi.python.org/pypi/pypiserver">pypiserver</a> software.</p> <p>This instance is running version {{VERSION}} of the
<a href="http://pypi.python.org/pypi/pypiserver">pypiserver</a> software.</p>
</body></html> </body></html>

View File

@ -8,13 +8,14 @@
pip>=7 pip>=7
setuptools setuptools
setuptools-git>=0.3 setuptools-git>=0.3
passlib
tox tox
wheel wheel
pytest>=2.3 pytest>=2.3
webtest; python_version != '2.5' webtest; python_version != '2.5'
mock; python_version <= '3.2' mock; python_version <= '3.2'
gevent>=1.1b4; python_version >= '3' gevent>=1.1b4; python_version >= '3'
twine>=1.6.0 twine>=1.6.1
WebOb==0.9.6.1; python_version == '2.5' WebOb==0.9.6.1; python_version == '2.5'
BeautifulSoup==3.2.1; python_version == '2.5' BeautifulSoup==3.2.1; python_version == '2.5'

View File

@ -9,12 +9,11 @@ if sys.version_info >= (3, 0):
else: else:
exec("def do_exec(co, loc): exec co in loc\n") exec("def do_exec(co, loc): exec co in loc\n")
tests_require = ['pytest>=2.3', 'tox', 'twine', 'pip>=7'] tests_require = ['pytest>=2.3', 'tox', 'twine', 'pip>=7', 'passlib']
if sys.version_info <= (3, 2): if sys.version_info <= (3, 2):
tests_require.append('mock') tests_require.append('mock')
def get_version(): def get_version():
d = {} d = {}
try: try:
@ -32,42 +31,43 @@ setup(name="pypiserver",
package_data={'pypiserver': ['welcome.html']}, package_data={'pypiserver': ['welcome.html']},
setup_requires=[ setup_requires=[
'setuptools', 'setuptools',
'setuptools-git >= 0.3', # Gather package-data from all files in git. # Gather package-data from all files in git.
'setuptools-git >= 0.3',
'wheel', 'wheel',
], ],
extras_require={ extras_require={
'passlib': ['passlib'] 'passlib': ['passlib']
}, },
tests_require=tests_require, tests_require=tests_require,
url="https://github.com/pypiserver/pypiserver", url="https://github.com/pypiserver/pypiserver",
maintainer="Kostis Anagnostopoulos", maintainer="Kostis Anagnostopoulos",
maintainer_email="ankostis@gmail.com", maintainer_email="ankostis@gmail.com",
classifiers=[ classifiers=[
"Development Status :: 5 - Production/Stable", "Development Status :: 5 - Production/Stable",
"Environment :: Web Environment", "Environment :: Web Environment",
"Intended Audience :: Developers", "Intended Audience :: Developers",
"Intended Audience :: System Administrators", "Intended Audience :: System Administrators",
"License :: OSI Approved :: BSD License", "License :: OSI Approved :: BSD License",
"License :: OSI Approved :: zlib/libpng License", "License :: OSI Approved :: zlib/libpng License",
"Operating System :: MacOS :: MacOS X", "Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows", "Operating System :: Microsoft :: Windows",
"Operating System :: POSIX", "Operating System :: POSIX",
"Operating System :: OS Independent", "Operating System :: OS Independent",
"Programming Language :: Python :: 2", "Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7", "Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.5",
"Topic :: Software Development :: Build Tools", "Topic :: Software Development :: Build Tools",
"Topic :: System :: Software Distribution"], "Topic :: System :: Software Distribution"],
zip_safe=True, zip_safe=True,
entry_points={ entry_points={
'paste.app_factory': ['main=pypiserver:paste_app_factory'], 'paste.app_factory': ['main=pypiserver:paste_app_factory'],
'console_scripts': ['pypi-server=pypiserver.__main__:main'] 'console_scripts': ['pypi-server=pypiserver.__main__:main']
}, },
options={ options={
'bdist_wheel': {'universal': True}, 'bdist_wheel': {'universal': True},
}, },

View File

@ -1,3 +0,0 @@
/build
/*egg*

View File

@ -1 +0,0 @@
/a-1.0-py3-none-any.whl

View File

@ -7,12 +7,14 @@ import functools
import os import os
import subprocess import subprocess
import sys import sys
import tempfile
import time import time
import pip import pip
from py import path # @UnresolvedImport from py import path # @UnresolvedImport
import pytest import pytest
_BUFF_SIZE = 4096 _BUFF_SIZE = 4096
_port = 8090 _port = 8090
@ -32,10 +34,11 @@ def _run_server(packdir, port, with_password, other_cli=''):
False: "-P. -a." False: "-P. -a."
} }
pswd_opts = pswd_opt_choices[with_password] pswd_opts = pswd_opt_choices[with_password]
cmd = "python -m pypiserver.__main__ -v --overwrite -p %s %s %s %s" % ( cmd = ("python -m pypiserver.__main__ -v --overwrite"
port, pswd_opts, other_cli, packdir) " -p %s %s %s %s" % (port, pswd_opts, other_cli, packdir))
proc = subprocess.Popen(cmd.split(), bufsize=_BUFF_SIZE) proc = subprocess.Popen(cmd.split(), bufsize=_BUFF_SIZE)
time.sleep(1) time.sleep(1)
assert proc.poll() is None
return Srv(proc, int(port), packdir) return Srv(proc, int(port), packdir)
@ -59,16 +62,40 @@ def new_server(packdir, port, with_password=False, other_cli=''):
_kill_server(srv) _kill_server(srv)
@contextlib.contextmanager
def chdir(d):
old_d = os.getcwd()
try:
os.chdir(d)
yield
finally:
os.chdir(old_d)
@pytest.fixture(scope='module') @pytest.fixture(scope='module')
def package(): def package(request):
dist_path = path.local('tests/centodeps/wheelhouse') def fin():
pkgs = list(dist_path.visit('centodeps*.whl')) tmpdir.remove(True)
assert len(pkgs) == 1 tmpdir = path.local(tempfile.mkdtemp())
request.addfinalizer(fin)
print(tmpdir)
src_setup_py = path.local().join('tests', 'centodeps-setup.py')
assert src_setup_py.check()
projdir = tmpdir.join('centodeps')
projdir.mkdir()
dst_setup_py = projdir.join('setup.py')
src_setup_py.copy(dst_setup_py)
assert dst_setup_py.check()
pkg = path.local(pkgs[0]) with chdir(projdir.strpath):
assert pkg.check() assert os.system('python setup.py bdist_wheel') == 0
pkgs = list(projdir.join('dist').visit('centodeps*.whl'))
assert len(pkgs) == 1
return pkg pkg = path.local(pkgs[0])
assert pkg.check()
return pkg
@pytest.fixture(scope='module') @pytest.fixture(scope='module')
@ -109,14 +136,6 @@ def pypirc(port):
} }
@pytest.fixture
def uploader(pypirc, monkeypatch):
from twine.commands import upload
monkeypatch.setattr(upload.utils, 'get_repository_from_config',
lambda *x: pypirc)
return upload
@pytest.fixture @pytest.fixture
def empty_packdir(tmpdir): def empty_packdir(tmpdir):
return tmpdir.mkdir("dists") return tmpdir.mkdir("dists")
@ -137,7 +156,7 @@ def _run_pip(cmd):
def _run_pip_install(cmd, port, install_dir, user=None, pswd=None): def _run_pip_install(cmd, port, install_dir, user=None, pswd=None):
url = _build_url(port, user, pswd) url = _build_url(port, user, pswd)
ncmd = 'install --download %s -i %s %s' % (install_dir, url, cmd) ncmd = '-vv install --download %s -i %s %s' % (install_dir, url, cmd)
return _run_pip(ncmd) return _run_pip(ncmd)
@ -172,6 +191,22 @@ def test_pipInstall_protectedOk(protected_server, package, pipdir):
assert pipdir.join(package.basename).check() assert pipdir.join(package.basename).check()
@pytest.fixture
def uploader(pypirc, monkeypatch):
from twine.commands import upload
monkeypatch.setattr(upload.utils, 'get_repository_from_config',
lambda *x: pypirc)
return upload
@pytest.fixture
def registerer(pypirc, monkeypatch):
from twine.commands import register
monkeypatch.setattr(register.utils, 'get_repository_from_config',
lambda *x: pypirc)
return register
@pytest.mark.skipif(sys.version_info[:2] == (3, 2), @pytest.mark.skipif(sys.version_info[:2] == (3, 2),
reason="urllib3 fails on twine (see https://travis-ci.org/ankostis/pypiserver/builds/81044993)") reason="urllib3 fails on twine (see https://travis-ci.org/ankostis/pypiserver/builds/81044993)")
def test_upload(empty_packdir, port, package, uploader): def test_upload(empty_packdir, port, package, uploader):
@ -186,21 +221,12 @@ def test_upload(empty_packdir, port, package, uploader):
assert empty_packdir.join( assert empty_packdir.join(
package.basename).check(), (package.basename, empty_packdir.listdir()) package.basename).check(), (package.basename, empty_packdir.listdir())
# def test_register_upload(protected_server, pypirc, package, pipdir):
# register(package, repository, username, password,
# comment=None, config_file=None)
# #
# @contextlib.contextmanager
# def chdir(d):
# old_d = os.getcwd()
# try:
# os.chdir('tests/centodeps')
# yield
# finally:
# os.chdir(old_d)
# def test_register_upload(open_server, pypirc, package, pipdir):
# with chdir('tests/centodeps'): # with chdir('tests/centodeps'):
# url = _build_url(open_server.port, user='a', pswd='a') # url = _build_url(open_server.port, user='a', pswd='a')
# cmd = "python setup.py register sdist upload -r %s" % url # cmd = "python setup.py --no-user-cfg register sdist upload -r %s" % url
# assert subprocess.Popen(cmd.split(), bufsize=_BUFF_SIZE) == 0 # assert subprocess.Popen(cmd.split(), bufsize=_BUFF_SIZE) == 0