mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2025-01-02 22:18:34 +01:00
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:
parent
19cdf80952
commit
3f4571d9e9
@ -1,11 +1,11 @@
|
|||||||
language: python
|
language: python
|
||||||
python: 2.7
|
python: 3.5
|
||||||
env:
|
env:
|
||||||
- TOX_ENV=py27
|
- TOX_ENV=py27
|
||||||
- TOX_ENV=py33
|
- TOX_ENV=py33
|
||||||
- TOX_ENV=py34
|
- TOX_ENV=py34
|
||||||
|
- TOX_ENV=py35
|
||||||
- TOX_ENV=pypy
|
- TOX_ENV=pypy
|
||||||
- TOX_ENV=cover
|
|
||||||
- TOX_ENV=flake8
|
- TOX_ENV=flake8
|
||||||
- TOX_ENV=pylint-errors
|
- TOX_ENV=pylint-errors
|
||||||
- TOX_ENV=pylint-full
|
- TOX_ENV=pylint-full
|
||||||
@ -15,7 +15,7 @@ install:
|
|||||||
- pip install python-coveralls
|
- pip install python-coveralls
|
||||||
script:
|
script:
|
||||||
- tox -e $TOX_ENV
|
- tox -e $TOX_ENV
|
||||||
after_success:
|
after_script:
|
||||||
- if [ "$TOX_ENV" = "py27" ]; then tox -e coveralls; fi
|
- if [ "$TOX_ENV" = "py35" ]; then tox -e coveralls; fi
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
14
bin/generate_travis_yml.py
Normal file → Executable file
14
bin/generate_travis_yml.py
Normal file → Executable file
@ -1,12 +1,16 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
# flake8: noqa
|
# flake8: noqa
|
||||||
|
|
||||||
|
import sys
|
||||||
import os
|
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("language: python")
|
||||||
print("python: 2.7")
|
print("python: 3.5")
|
||||||
print("env:")
|
print("env:")
|
||||||
for env in parseconfig(None, 'tox').envlist:
|
for env in parseconfig(None, 'tox').envlist:
|
||||||
print(" - TOX_ENV=%s" % env)
|
print(" - TOX_ENV=%s" % env)
|
||||||
@ -15,7 +19,7 @@ print(" - pip install tox")
|
|||||||
print(" - pip install python-coveralls")
|
print(" - pip install python-coveralls")
|
||||||
print("script:")
|
print("script:")
|
||||||
print(" - tox -e $TOX_ENV")
|
print(" - tox -e $TOX_ENV")
|
||||||
print("after_success:")
|
print("after_script:")
|
||||||
print(' - if [ "$TOX_ENV" = "py27 ]; then tox -e coveralls; fi')
|
print(' - if [ "$TOX_ENV" = "py35" ]; then tox -e coveralls; fi')
|
||||||
print("notifications:")
|
print("notifications:")
|
||||||
print(" email: false")
|
print(" email: false")
|
||||||
|
@ -7,6 +7,7 @@ from minecraft.exceptions import YggdrasilError
|
|||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import unittest
|
import unittest
|
||||||
|
import os
|
||||||
from .compat import mock
|
from .compat import mock
|
||||||
|
|
||||||
FAKE_DATA = {
|
FAKE_DATA = {
|
||||||
@ -56,6 +57,14 @@ def should_skip_cred_test():
|
|||||||
return False
|
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):
|
class InitProfile(unittest.TestCase):
|
||||||
def test_init_no_values(self):
|
def test_init_no_values(self):
|
||||||
p = Profile()
|
p = Profile()
|
||||||
@ -194,6 +203,8 @@ class AuthenticateAuthenticationToken(unittest.TestCase):
|
|||||||
self.assertTrue(resp)
|
self.assertTrue(resp)
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipUnless(should_run_internet_tests(),
|
||||||
|
"Tests involving Internet access are disabled.")
|
||||||
class MakeRequest(unittest.TestCase):
|
class MakeRequest(unittest.TestCase):
|
||||||
def test_make_request_http_method(self):
|
def test_make_request_http_method(self):
|
||||||
res = _make_request(AUTHSERVER, "authenticate", {"Billy": "Bob"})
|
res = _make_request(AUTHSERVER, "authenticate", {"Billy": "Bob"})
|
||||||
|
38
tox.ini
38
tox.ini
@ -4,7 +4,7 @@
|
|||||||
# and then run "tox" from this directory.
|
# and then run "tox" from this directory.
|
||||||
|
|
||||||
[tox]
|
[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]
|
[testenv]
|
||||||
commands = nosetests
|
commands = nosetests
|
||||||
@ -15,20 +15,7 @@ deps =
|
|||||||
cryptography
|
cryptography
|
||||||
future
|
future
|
||||||
|
|
||||||
[testenv:py27]
|
|
||||||
deps =
|
|
||||||
{[testenv]deps}
|
|
||||||
mock
|
|
||||||
|
|
||||||
[testenv:pypy]
|
|
||||||
deps =
|
|
||||||
{[testenv]deps}
|
|
||||||
mock
|
|
||||||
|
|
||||||
[testenv:cover]
|
[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 =
|
deps =
|
||||||
{[testenv]deps}
|
{[testenv]deps}
|
||||||
coverage
|
coverage
|
||||||
@ -36,14 +23,29 @@ deps =
|
|||||||
|
|
||||||
[testenv:coveralls]
|
[testenv:coveralls]
|
||||||
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
|
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
|
||||||
basepython = {[testenv:cover]basepython}
|
|
||||||
commands =
|
commands =
|
||||||
{[testenv:cover]commands}
|
|
||||||
coveralls
|
coveralls
|
||||||
deps =
|
deps =
|
||||||
{[testenv:cover]deps}
|
|
||||||
coveralls
|
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]
|
[testenv:flake8]
|
||||||
basepython = python3.5
|
basepython = python3.5
|
||||||
commands =
|
commands =
|
||||||
@ -82,4 +84,4 @@ deps =
|
|||||||
check-manifest
|
check-manifest
|
||||||
commands =
|
commands =
|
||||||
check-manifest
|
check-manifest
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user