Update testing configuration:

(1) Add py35 job to Travis.
(2) To address issue #57: run tests that connect to Mojang's auth server exactly once, during the py35 job.
(3) Measure coverage exactly once, during the py35 job; always submit the result to coveralls.
(4) Fix miscellaneous errors in generate_travis_yml.py.
This commit is contained in:
joo 2017-05-19 11:58:14 +01:00
parent 19cdf80952
commit 3f4571d9e9
4 changed files with 44 additions and 27 deletions

View File

@ -1,11 +1,11 @@
language: python
python: 2.7
python: 3.5
env:
- TOX_ENV=py27
- TOX_ENV=py33
- TOX_ENV=py34
- TOX_ENV=py35
- TOX_ENV=pypy
- TOX_ENV=cover
- TOX_ENV=flake8
- TOX_ENV=pylint-errors
- TOX_ENV=pylint-full
@ -15,7 +15,7 @@ install:
- pip install python-coveralls
script:
- tox -e $TOX_ENV
after_success:
- if [ "$TOX_ENV" = "py27" ]; then tox -e coveralls; fi
after_script:
- if [ "$TOX_ENV" = "py35" ]; then tox -e coveralls; fi
notifications:
email: false

14
bin/generate_travis_yml.py Normal file → Executable file
View File

@ -1,12 +1,16 @@
#!/usr/bin/env python
# flake8: noqa
import sys
import os
os.chdir("..")
import os.path
from tox.config import parseconfig
from tox._config import parseconfig
# This file is in pyCraft/bin/; it needs to execute in pyCraft/.
os.chdir(os.path.join(os.path.dirname(__file__), ".."))
print("language: python")
print("python: 2.7")
print("python: 3.5")
print("env:")
for env in parseconfig(None, 'tox').envlist:
print(" - TOX_ENV=%s" % env)
@ -15,7 +19,7 @@ print(" - pip install tox")
print(" - pip install python-coveralls")
print("script:")
print(" - tox -e $TOX_ENV")
print("after_success:")
print(' - if [ "$TOX_ENV" = "py27 ]; then tox -e coveralls; fi')
print("after_script:")
print(' - if [ "$TOX_ENV" = "py35" ]; then tox -e coveralls; fi')
print("notifications:")
print(" email: false")

View File

@ -7,6 +7,7 @@ from minecraft.exceptions import YggdrasilError
import requests
import json
import unittest
import os
from .compat import mock
FAKE_DATA = {
@ -56,6 +57,14 @@ def should_skip_cred_test():
return False
def should_run_internet_tests():
"""
Returns `True` if tests involving access to Internet resources
should *not* be skipped. Otherwise returns `False`.
"""
return os.environ.get('PYCRAFT_RUN_INTERNET_TESTS')
class InitProfile(unittest.TestCase):
def test_init_no_values(self):
p = Profile()
@ -194,6 +203,8 @@ class AuthenticateAuthenticationToken(unittest.TestCase):
self.assertTrue(resp)
@unittest.skipUnless(should_run_internet_tests(),
"Tests involving Internet access are disabled.")
class MakeRequest(unittest.TestCase):
def test_make_request_http_method(self):
res = _make_request(AUTHSERVER, "authenticate", {"Billy": "Bob"})

38
tox.ini
View File

@ -4,7 +4,7 @@
# and then run "tox" from this directory.
[tox]
envlist = py27, py33, py34, py35, py36, pypy, cover, flake8, pylint-errors, pylint-full, verify-manifest
envlist = py27, py33, py34, py35, pypy, flake8, pylint-errors, pylint-full, verify-manifest
[testenv]
commands = nosetests
@ -15,20 +15,7 @@ deps =
cryptography
future
[testenv:py27]
deps =
{[testenv]deps}
mock
[testenv:pypy]
deps =
{[testenv]deps}
mock
[testenv:cover]
basepython = python3.5
commands =
nosetests --with-xunit --with-xcoverage --cover-package=minecraft --nocapture --cover-erase --cover-inclusive --cover-tests --cover-branches --cover-min-percentage=60
deps =
{[testenv]deps}
coverage
@ -36,14 +23,29 @@ deps =
[testenv:coveralls]
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
basepython = {[testenv:cover]basepython}
commands =
{[testenv:cover]commands}
coveralls
deps =
{[testenv:cover]deps}
coveralls
[testenv:py27]
deps =
{[testenv]deps}
mock
[testenv:py35]
setenv =
PYCRAFT_RUN_INTERNET_TESTS=1
commands =
nosetests --with-xunit --with-xcoverage --cover-package=minecraft --cover-erase --cover-inclusive --cover-tests --cover-branches --cover-min-percentage=60
deps =
{[testenv:cover]deps}
[testenv:pypy]
deps =
{[testenv]deps}
mock
[testenv:flake8]
basepython = python3.5
commands =
@ -82,4 +84,4 @@ deps =
check-manifest
commands =
check-manifest