Skip to content

Commit f85b827

Browse files
committed
FIX: console script invokation fails, add tests to catch it
1 parent f1f017d commit f85b827

File tree

6 files changed

+29
-9
lines changed

6 files changed

+29
-9
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ matrix:
2828
language: generic
2929

3030
before_install:
31+
- pyenv versions
3132
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source .travis-osx; fi
32-
# work around https://github.com/travis-ci/travis-ci/issues/8363
33-
- if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then pyenv global system 3.5; fi
34-
33+
3534
install:
3635
- pip install -U six
3736
- pip install --pre -U tox

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def main():
4343
author='holger krekel',
4444
author_email='[email protected]',
4545
packages=['tox'],
46-
entry_points={'console_scripts': 'tox=tox:cmdline\ntox-quickstart=tox._quickstart:main'},
46+
entry_points={'console_scripts': ['tox=tox:cmdline',
47+
'tox-quickstart=tox._quickstart:main']},
4748
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
4849
setup_requires=['setuptools_scm'],
4950
install_requires=['py>=1.4.17',

tests/test_z_cmdline.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
22
import platform
33
import re
4+
import subprocess
5+
import sys
46

57
import py
68
import pytest
@@ -865,3 +867,19 @@ def test_missing_env_fails(initproj, cmd):
865867
assert result.ret == 1
866868
assert result.out.endswith("foo: unresolvable substitution(s): 'VAR'."
867869
" Environment variables are missing or defined recursively.\n")
870+
871+
872+
def test_tox_console_script():
873+
result = subprocess.check_call(['tox', '--help'])
874+
assert result == 0
875+
876+
877+
def test_tox_quickstart_script():
878+
result = subprocess.check_call(['tox-quickstart', '--help'])
879+
assert result == 0
880+
881+
882+
def test_tox_cmdline(monkeypatch):
883+
monkeypatch.setattr(sys, 'argv', ['caller_scrip', '--help'])
884+
with pytest.raises(SystemExit):
885+
tox.cmdline()

tox/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ def __init__(self, message):
5252
super(exception.MinVersionError, self).__init__(message)
5353

5454

55-
from tox.session import main as cmdline # noqa
55+
from .session import run_main as cmdline # noqa
5656

5757
__all__ = ('hookspec', 'hookimpl', 'cmdline', 'exception', '__version__')

tox/__main__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import sys
2-
3-
from tox.session import main
1+
from tox.session import run_main
42

53
if __name__ == '__main__':
6-
main(sys.argv[1:])
4+
run_main()

tox/session.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ def prepare(args):
3434
return config
3535

3636

37+
def run_main():
38+
main(sys.argv[1:])
39+
40+
3741
def main(args):
3842
try:
3943
config = prepare(args)

0 commit comments

Comments
 (0)