import tox._quickstart

class TestToxQuickstart(object):
    def test_pytest(self, tmpdir):
        d = {
            'envlist': 'py24, py25, py26, py27, py32, py33, pypy',
            'commands': 'py.test',
            'deps': 'pytest',
        }
        expected_tox_ini = """
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
envlist = py24, py25, py26, py27, py32, py33, pypy

[testenv]
commands = py.test
deps = pytest
""".lstrip()
        tox._quickstart.generate(d)
        result = open('tox.ini').read()
        # print(result)
        assert(result == expected_tox_ini)

    def test_setup_py_test(self, tmpdir):
        d = {
            'envlist': 'py26, py27',
            'commands': 'python setup.py test',
            'deps': '',
        }
        expected_tox_ini = """
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
envlist = py26, py27

[testenv]
commands = python setup.py test
deps = 
""".lstrip()
        tox._quickstart.generate(d)
        result = open('tox.ini').read()
        # print(result)
        assert(result == expected_tox_ini)

    def test_trial(self, tmpdir):
        d = {
            'envlist': 'py27',
            'commands': 'trial',
            'deps': 'Twisted',
        }
        expected_tox_ini = """
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
envlist = py27

[testenv]
commands = trial
deps = Twisted
""".lstrip()
        tox._quickstart.generate(d)
        result = open('tox.ini').read()
        # print(result)
        assert(result == expected_tox_ini)

    def test_nosetests(self, tmpdir):
        d = {
            'envlist': 'py27, py32, py33, pypy',
            'commands': 'nosetests -v',
            'deps': 'nose',
        }
        expected_tox_ini = """
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
envlist = py27, py32, py33, pypy

[testenv]
commands = nosetests -v
deps = nose
""".lstrip()
        tox._quickstart.generate(d)
        result = open('tox.ini').read()
        # print(result)
        assert(result == expected_tox_ini)

@@ -1,8 +1,19 @@
+import os%0A%0A
 import t
@@ -28,16 +28,1118 @@
 kstart%0A%0A
+%0Aclass TestToxQuickstartMain(object):%0A    def test_quickstart_main(self, monkeypatch, tmpdir):%0A        def mock_term_input_return_values():%0A            for return_val in %5B'Y', 'Y', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'py.test', 'pytest'%5D:%0A                yield return_val%0A                %0A        generator = mock_term_input_return_values()%0A                %0A        def mock_term_input(prompt):%0A            return generator.next()%0A                %0A        monkeypatch.setattr(tox._quickstart, 'term_input', mock_term_input)%0A        %0A        tox._quickstart.main(argv=%5B'tox-quickstart'%5D)%0A        %0A        expected_tox_ini = %22%22%22%0A# Tox (http://tox.testrun.org/) is a tool for running tests%0A# in multiple virtualenvs. This configuration file will run the%0A# test suite on all supported python versions. To use it, %22pip install tox%22%0A# and then run %22tox%22 from this directory.%0A%0A%5Btox%5D%0Aenvlist = py24, py25, py26, py27, py32, py33, pypy%0A%0A%5Btestenv%5D%0Acommands = py.test%0Adeps = %0A    pytest%0A%22%22%22.lstrip()%0A        result = open('tox.ini').read()%0A        print(result)%0A        assert(result == expected_tox_ini)%0A%09%09%0A%0A
 class Te

Add TestToxQuickstartMain for testing tox-quickstart at a higher level (calling tox._quickstart.main)