Skip to content

Commit 999077f

Browse files
authored
Merge pull request #407 from rogalski/warn-about-commands-missing
Warn about commands key missing in tox.ini
2 parents ae018c4 + aa36bc3 commit 999077f

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

CHANGELOG

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
- fix #399. Make sure {envtmpdir} is created if it doesn't exist at the
3838
start of a testenvironment run. Thanks Manuel Jacob.
3939

40+
- fix #316: Lack of commands key in ini file is now treated as an error.
41+
Reported virtualenv status is 'nothing to do' instead of 'commands
42+
succeeded', with relevant error message displayed. Thanks Lukasz Rogalski.
4043

4144
2.4.1
4245
-----

tests/test_venv.py

+13
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ def test_run_install_command(newmocksession):
610610
def test_run_custom_install_command(newmocksession):
611611
mocksession = newmocksession([], """
612612
[testenv]
613+
commands={envpython} --version
613614
install_command=easy_install {opts} {packages}
614615
""")
615616
venv = mocksession.getenv('python')
@@ -626,6 +627,7 @@ def test_run_custom_install_command(newmocksession):
626627
def test_command_relative_issue26(newmocksession, tmpdir, monkeypatch):
627628
mocksession = newmocksession([], """
628629
[testenv]
630+
commands={envpython} --version
629631
""")
630632
x = tmpdir.ensure("x")
631633
venv = mocksession.getenv("python")
@@ -700,3 +702,14 @@ def tox_runtest_post(self, venv):
700702
assert l == []
701703
mocksession.runtestenv(venv)
702704
assert l == ['started', 'finished']
705+
706+
707+
def test_error_when_commands_missing(newmocksession):
708+
mocksession = newmocksession([], """
709+
[testenv]
710+
""")
711+
712+
venv = mocksession.getenv('python')
713+
venv.status = None
714+
mocksession.runtestenv(venv)
715+
assert venv.status == 'nothing to do'

tests/test_z_cmdline.py

+27-3
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ def test_venv_special_chars_issue252(cmd, initproj):
351351
'tox.ini': '''
352352
[tox]
353353
envlist = special&&1
354+
[testenv]
355+
commands={envpython} --version
354356
[testenv:special&&1]
355357
changedir=tests
356358
'''
@@ -468,7 +470,10 @@ def test_package_install_fails(cmd, initproj):
468470
install_requires=['qweqwe123'],
469471
)
470472
""",
471-
'tox.ini': '',
473+
'tox.ini': """
474+
[testenv]
475+
commands={envpython} --version
476+
""",
472477
})
473478
result = cmd.run("tox", )
474479
assert result.ret
@@ -541,6 +546,8 @@ def test_json(self, cmd, example123):
541546

542547
def test_develop(initproj, cmd):
543548
initproj("example123", filedefs={'tox.ini': """
549+
[testenv]
550+
commands={envpython} --version
544551
"""})
545552
result = cmd.run("tox", "-vv", "--develop")
546553
assert not result.ret
@@ -550,6 +557,7 @@ def test_develop(initproj, cmd):
550557
def test_usedevelop(initproj, cmd):
551558
initproj("example123", filedefs={'tox.ini': """
552559
[testenv]
560+
commands={envpython} --version
553561
usedevelop=True
554562
"""})
555563
result = cmd.run("tox", "-vv")
@@ -559,6 +567,8 @@ def test_usedevelop(initproj, cmd):
559567

560568
def test_usedevelop_mixed(initproj, cmd):
561569
initproj("example123", filedefs={'tox.ini': """
570+
[testenv]
571+
commands={envpython} --version
562572
[testenv:devenv]
563573
usedevelop=True
564574
[testenv:nondev]
@@ -648,6 +658,7 @@ def test_notest(initproj, cmd):
648658
initproj("example123", filedefs={'tox.ini': """
649659
# content of: tox.ini
650660
[testenv:py26]
661+
commands={envpython} --version
651662
basepython=python
652663
"""})
653664
result = cmd.run("tox", "-v", "--notest")
@@ -664,7 +675,10 @@ def test_notest(initproj, cmd):
664675

665676

666677
def test_PYC(initproj, cmd, monkeypatch):
667-
initproj("example123", filedefs={'tox.ini': ''})
678+
initproj("example123", filedefs={'tox.ini': """
679+
[testenv]
680+
commands={envpython} --version
681+
"""})
668682
monkeypatch.setenv("PYTHONDOWNWRITEBYTECODE", 1)
669683
result = cmd.run("tox", "-v", "--notest")
670684
assert not result.ret
@@ -674,7 +688,10 @@ def test_PYC(initproj, cmd, monkeypatch):
674688

675689

676690
def test_env_VIRTUALENV_PYTHON(initproj, cmd, monkeypatch):
677-
initproj("example123", filedefs={'tox.ini': ''})
691+
initproj("example123", filedefs={'tox.ini': """
692+
[testenv]
693+
commands={envpython} --version
694+
"""})
678695
monkeypatch.setenv("VIRTUALENV_PYTHON", '/FOO')
679696
result = cmd.run("tox", "-v", "--notest")
680697
assert not result.ret, result.stdout.lines
@@ -700,6 +717,8 @@ def test_separate_sdist_no_sdistfile(cmd, initproj):
700717
'tox.ini': """
701718
[tox]
702719
distshare=%s
720+
[testenv]
721+
commands={envpython} --version
703722
""" % distshare
704723
})
705724
result = cmd.run("tox", "--sdistonly")
@@ -717,6 +736,8 @@ def test_separate_sdist(cmd, initproj):
717736
[tox]
718737
distshare=%s
719738
sdistsrc={distshare}/pkg123-0.7.zip
739+
[testenv]
740+
commands={envpython} --version
720741
""" % distshare
721742
})
722743
result = cmd.run("tox", "--sdistonly")
@@ -737,6 +758,8 @@ def test_sdist_latest(tmpdir, newconfig):
737758
[tox]
738759
distshare=%s
739760
sdistsrc={distshare}/pkg123-*
761+
[testenv]
762+
commands={envpython} --version
740763
""" % distshare)
741764
p = distshare.ensure("pkg123-1.4.5.zip")
742765
distshare.ensure("pkg123-1.4.5a1.zip")
@@ -789,6 +812,7 @@ def test_verbosity(cmd, initproj, verbosity):
789812
initproj("pkgX-0.0.5", filedefs={
790813
'tox.ini': """
791814
[testenv]
815+
commands={envpython} --version
792816
"""})
793817
result = cmd.run("tox", verbosity)
794818
assert result.ret == 0

tox/session.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,11 @@ def subcommand_test(self):
565565
return retcode
566566

567567
def runtestenv(self, venv, redirect=False):
568-
if not self.config.option.notest:
568+
if not venv.envconfig.commands:
569+
self.report.error(("Commands not specified. Please update "
570+
"relevant section of {0}").format(self.config.toxinipath))
571+
venv.status = "nothing to do"
572+
elif not self.config.option.notest:
569573
if venv.status:
570574
return
571575
self.hook.tox_runtest_pre(venv=venv)

0 commit comments

Comments
 (0)