1. Marc Abramowitz
  2. tox_quickstart

Commits

Marc Abramowitz  committed d750e3e Draft

Automatically add "pytest" to deps when the selected test runner is py.test

  • Participants
  • Parent commits 3e3de96
  • Branches default

Comments (0)

Files changed (2)

File tests/test_quickstart.py

View file
  • Ignore whitespace
                 
         return mock_term_input
                 
-    def test_quickstart_main(self, monkeypatch, tmpdir):
+    def test_quickstart_main_pytest_1(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']))
         result = open('tox.ini').read()
         assert(result == expected_tox_ini)
 		
+    def test_quickstart_main_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', '']))
+
+        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, py32, py33, pypy
+
+[testenv]
+commands = py.test
+deps = 
+    pytest
+""".lstrip()
+        result = open('tox.ini').read()
+        assert(result == expected_tox_ini)
+
     def test_quickstart_main_defaults(self, monkeypatch, tmpdir):
         monkeypatch.setattr(
             tox._quickstart, 'term_input', 

File tox/_quickstart.py

View file
  • Ignore whitespace
     - trial package.module''')
     do_prompt(d, 'commands', 'Command to run to test project', '{envpython} setup.py test')
 
+    default_deps = ' '
+    if 'py.test' in d['commands']:
+        default_deps = 'pytest'
+        
     print('''
 What dependencies does your project have?''')
-    do_prompt(d, 'deps', 'Comma-separated list of dependencies', ' ')
+    do_prompt(d, 'deps', 'Comma-separated list of dependencies', default_deps)
 
 
 def process_input(d):