Commits

Marc Abramowitz committed 619f140

Changed the Python version selection so that there are a bunch of
pre-canned choices so that you can quickly pick one and not have to
answer a yes/no question 10 times

Comments (0)

Files changed (2)

tests/test_quickstart.py

                 
         return mock_term_input
                 
-    def test_quickstart_main_pytest_1(self, monkeypatch, tmpdir):
+    def test_quickstart_main_choose_individual_pythons_and_pytest(self, monkeypatch, tmpdir):
         monkeypatch.setattr(
             tox._quickstart, 'term_input', 
-            self.get_mock_term_input(['Y', 'Y', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'py.test', 'pytest']))
+            self.get_mock_term_input(['4', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'py.test', 'pytest']))
         
         tox._quickstart.main(argv=['tox-quickstart'])
         
         result = open('tox.ini').read()
         assert(result == expected_tox_ini)
 		
-    def test_quickstart_main_nose_adds_deps(self, monkeypatch, tmpdir):
+    def test_quickstart_main_choose_individual_pythons_and_nose_adds_deps(self, monkeypatch, tmpdir):
         monkeypatch.setattr(
             tox._quickstart, 'term_input', 
-            self.get_mock_term_input(['Y', 'Y', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'nosetests', '']))
+            self.get_mock_term_input(['4', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'nosetests', '']))
 
         tox._quickstart.main(argv=['tox-quickstart'])
 
         result = open('tox.ini').read()
         assert(result == expected_tox_ini)
 
-    def test_quickstart_main_trial_adds_deps(self, monkeypatch, tmpdir):
+    def test_quickstart_main_choose_individual_pythons_and_trial_adds_deps(self, monkeypatch, tmpdir):
         monkeypatch.setattr(
             tox._quickstart, 'term_input', 
-            self.get_mock_term_input(['Y', 'Y', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'trial', '']))
+            self.get_mock_term_input(['4', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'trial', '']))
 
         tox._quickstart.main(argv=['tox-quickstart'])
 
         result = open('tox.ini').read()
         assert(result == expected_tox_ini)
 
-    def test_quickstart_main_pytest_adds_deps(self, monkeypatch, tmpdir):
+    def test_quickstart_main_choose_individual_pythons_and_pytest_adds_deps(self, monkeypatch, tmpdir):
         monkeypatch.setattr(
             tox._quickstart, 'term_input', 
-            self.get_mock_term_input(['Y', 'Y', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'py.test', '']))
+            self.get_mock_term_input(['4', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'py.test', '']))
 
         tox._quickstart.main(argv=['tox-quickstart'])
 
         result = open('tox.ini').read()
         assert(result == expected_tox_ini)
 
-    def test_quickstart_main_defaults(self, monkeypatch, tmpdir):
+    def test_quickstart_main_choose_py27_and_pytest_adds_deps(self, monkeypatch, tmpdir):
         monkeypatch.setattr(
             tox._quickstart, 'term_input', 
-            self.get_mock_term_input(['', '', '', '', '', '', '', '', '', '', '', '']))
+            self.get_mock_term_input(['1', 'py.test', '']))
+
+        tox._quickstart.main(argv=['tox-quickstart'])
+
+        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 = py.test
+deps = 
+    pytest
+""".lstrip()
+        result = open('tox.ini').read()
+        assert(result == expected_tox_ini)
+
+    def test_quickstart_main_choose_py27_and_py33_and_pytest_adds_deps(self, monkeypatch, tmpdir):
+        monkeypatch.setattr(
+            tox._quickstart, 'term_input', 
+            self.get_mock_term_input(['2', 'py.test', '']))
+
+        tox._quickstart.main(argv=['tox-quickstart'])
+
+        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, py33
+
+[testenv]
+commands = py.test
+deps = 
+    pytest
+""".lstrip()
+        result = open('tox.ini').read()
+        assert(result == expected_tox_ini)
+
+    def test_quickstart_main_choose_all_pythons_and_pytest_adds_deps(self, monkeypatch, tmpdir):
+        monkeypatch.setattr(
+            tox._quickstart, 'term_input', 
+            self.get_mock_term_input(['3', 'py.test', '']))
+
+        tox._quickstart.main(argv=['tox-quickstart'])
+
+        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, py30, py31, py32, py33, pypy, jython
+
+[testenv]
+commands = py.test
+deps = 
+    pytest
+""".lstrip()
+        result = open('tox.ini').read()
+        assert(result == expected_tox_ini)
+
+    def test_quickstart_main_choose_individual_pythons_and_defaults(self, monkeypatch, tmpdir):
+        monkeypatch.setattr(
+            tox._quickstart, 'term_input', 
+            self.get_mock_term_input(['4', '', '', '', '', '', '', '', '', '', '', '', '']))
 
         tox._quickstart.main(argv=['tox-quickstart'])
 

tox/_quickstart.py

 accept a default value, if one is given in brackets).''')
 
     print
-
-    for pyenv in all_envs:
-        if pyenv not in d:
-            do_prompt(d, pyenv, 'Test your project with %s (Y/n)' % pyenv, 'Y', boolean)
+    
+    print('''
+What Python versions do you want to test against? Choices:
+    [1] py27
+    [2] py27, py33
+    [3] (All versions) %s
+    [4] Choose each one-by-one''' % ', '.join(all_envs))
+    do_prompt(d, 'canned_pyenvs', 'Enter the number of your choice', 
+        '3', choice('1', '2', '3', '4'))
+        
+    if d['canned_pyenvs'] == '1':
+        d['py27'] = True
+    elif d['canned_pyenvs'] == '2':
+        for pyenv in ('py27', 'py33'):
+            d[pyenv] = True
+    elif d['canned_pyenvs'] == '3':
+        for pyenv in all_envs:
+            d[pyenv] = True
+    elif d['canned_pyenvs'] == '4':
+        for pyenv in all_envs:
+            if pyenv not in d:
+                do_prompt(d, pyenv, 'Test your project with %s (Y/n)' % pyenv, 'Y', boolean)
 
     print('''
 What command should be used to test your project -- examples: