Update Tests for New Twine

* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls

We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:

```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```

Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.

This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
This commit is contained in:
Matthew Planchard 2016-07-17 13:40:06 -05:00
parent 117a61ed14
commit a05d5a103b
4 changed files with 31 additions and 10 deletions

3
.gitignore vendored

@ -34,3 +34,6 @@ __pycache__/
/parts/
/.cache/
/.settings/
# IDE stuff
.idea/

@ -8,9 +8,11 @@ env:
- TOX_ENV=py35
- TOX_ENV=pypy
install:
- pip install -U setuptools pip sphinx tox
script:
- ./bin/test_standalone.sh
- python -m pip install setuptools pip sphinx tox -U
- tox -e $TOX_ENV
- ./bin/check_readme.sh

@ -15,7 +15,7 @@ pytest>=2.3
webtest; python_version != '2.5'
mock; python_version <= '3.2'
gevent>=1.1b4; python_version >= '3'
twine>=1.6.1
twine>=1.7
WebOb==0.9.6.1; python_version == '2.5'
BeautifulSoup==3.2.1; python_version == '2.5'

@ -280,14 +280,18 @@ def test_setuptoolsUpload_authed(empty_packdir, port, project, package,
@pytest.fixture
def uploader(pypirc, monkeypatch):
"""Return an uploader module with appropriate utils methods mocked"""
from twine.commands import upload
monkeypatch.setattr(upload.utils, 'get_repository_from_config',
lambda *x: pypirc)
monkeypatch.setattr(upload.utils, 'get_cacert', lambda *x: None)
monkeypatch.setattr(upload.utils, 'get_clientcert', lambda *x: None)
return upload
@pytest.fixture
def registerer(pypirc, monkeypatch):
"""Return register module with appropriate utils methods mocked"""
from twine.commands import register
monkeypatch.setattr(register.utils, 'get_repository_from_config',
lambda *x: pypirc)
@ -295,8 +299,10 @@ def registerer(pypirc, monkeypatch):
@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_twineUpload_open(empty_packdir, port, package, uploader, pypirc):
"""Test twine upload with no authentication"""
user, pswd = 'foo', 'bar'
update_pypirc(pypirc, port, user=user, pswd=pswd)
with new_server(empty_packdir, port):
@ -304,14 +310,17 @@ def test_twineUpload_open(empty_packdir, port, package, uploader, pypirc):
sign=None, identity=None,
username=user, password=pswd,
comment=None, sign_with=None,
config_file=None, skip_existing=None)
config_file=None, skip_existing=None,
cert=None, client_cert=None)
time.sleep(SLEEP_AFTER_SRV)
assert len(empty_packdir.listdir()) == 1
@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_twineUpload_authed(empty_packdir, port, package, uploader, pypirc):
"""Test authenticated twine upload"""
user, pswd = 'a', 'a'
update_pypirc(pypirc, port, user=user, pswd=pswd)
with new_server(empty_packdir, port, authed=False):
@ -319,7 +328,8 @@ def test_twineUpload_authed(empty_packdir, port, package, uploader, pypirc):
sign=None, identity=None,
username=user, password=pswd,
comment=None, sign_with=None,
config_file=None, skip_existing=None)
config_file=None, skip_existing=None,
cert=None, client_cert=None)
time.sleep(SLEEP_AFTER_SRV)
assert len(empty_packdir.listdir()) == 1
@ -328,21 +338,27 @@ def test_twineUpload_authed(empty_packdir, port, package, uploader, pypirc):
@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_twineRegister_open(open_server, package, registerer, pypirc):
"""Test unauthenticated twine registration"""
srv = open_server
update_pypirc(pypirc, srv.port)
registerer.register(package.strpath, repository='test',
username='foo', password='bar',
comment=None, config_file=None)
comment=None, config_file=None,
cert=None, client_cert=None)
@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_twineRegister_authedOk(protected_server, package, registerer, pypirc):
"""Test authenticated twine registration"""
srv = protected_server
user, pswd = 'a', 'a'
update_pypirc(pypirc, srv.port, user=user, pswd=pswd)
registerer.register(package.strpath, repository='test',
username=user, password=pswd,
comment=None, config_file=None)
comment=None, config_file=None,
cert=None, client_cert=None)