Commits

Anonymous committed 53028f8

Make tests/test_quickstart.py tests run in a temporary directory so
they don't attempt to clobber tox.ini in current directory.

Comments (0)

Files changed (1)

tests/test_quickstart.py

+import os
+import tempfile
+import pytest
 import tox._quickstart
 
 
+@pytest.fixture()
+def cleandir():
+    newpath = tempfile.mkdtemp()
+    os.chdir(newpath)
+
+
+@pytest.mark.usefixtures("cleandir")
 class TestToxQuickstartMain(object):
     def mock_term_input_return_values(self, return_values):
         for return_val in return_values:
                 return generator.next()
                 
         return mock_term_input
-                
-    def test_quickstart_main_choose_individual_pythons_and_pytest(self, monkeypatch, tmpdir):
+
+    def test_quickstart_main_choose_individual_pythons_and_pytest(self, monkeypatch):
         monkeypatch.setattr(
             tox._quickstart, 'term_input', 
             self.get_mock_term_input(['4', '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_choose_individual_pythons_and_nose_adds_deps(self, monkeypatch, tmpdir):
+    def test_quickstart_main_choose_individual_pythons_and_nose_adds_deps(self, monkeypatch):
         monkeypatch.setattr(
             tox._quickstart, 'term_input', 
             self.get_mock_term_input(['4', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'nosetests', '']))
         result = open('tox.ini').read()
         assert(result == expected_tox_ini)
 
-    def test_quickstart_main_choose_individual_pythons_and_trial_adds_deps(self, monkeypatch, tmpdir):
+    def test_quickstart_main_choose_individual_pythons_and_trial_adds_deps(self, monkeypatch):
         monkeypatch.setattr(
             tox._quickstart, 'term_input', 
             self.get_mock_term_input(['4', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'trial', '']))
         result = open('tox.ini').read()
         assert(result == expected_tox_ini)
 
-    def test_quickstart_main_choose_individual_pythons_and_pytest_adds_deps(self, monkeypatch, tmpdir):
+    def test_quickstart_main_choose_individual_pythons_and_pytest_adds_deps(self, monkeypatch):
         monkeypatch.setattr(
             tox._quickstart, 'term_input', 
             self.get_mock_term_input(['4', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'py.test', '']))
         result = open('tox.ini').read()
         assert(result == expected_tox_ini)
 
-    def test_quickstart_main_choose_py27_and_pytest_adds_deps(self, monkeypatch, tmpdir):
+    def test_quickstart_main_choose_py27_and_pytest_adds_deps(self, monkeypatch):
         monkeypatch.setattr(
             tox._quickstart, 'term_input', 
             self.get_mock_term_input(['1', 'py.test', '']))
         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):
+    def test_quickstart_main_choose_py27_and_py33_and_pytest_adds_deps(self, monkeypatch):
         monkeypatch.setattr(
             tox._quickstart, 'term_input', 
             self.get_mock_term_input(['2', 'py.test', '']))
         result = open('tox.ini').read()
         assert(result == expected_tox_ini)
 
-    def test_quickstart_main_choose_all_pythons_and_pytest_adds_deps(self, monkeypatch, tmpdir):
+    def test_quickstart_main_choose_all_pythons_and_pytest_adds_deps(self, monkeypatch):
         monkeypatch.setattr(
             tox._quickstart, 'term_input', 
             self.get_mock_term_input(['3', 'py.test', '']))
         result = open('tox.ini').read()
         assert(result == expected_tox_ini)
 
-    def test_quickstart_main_choose_individual_pythons_and_defaults(self, monkeypatch, tmpdir):
+    def test_quickstart_main_choose_individual_pythons_and_defaults(self, monkeypatch):
         monkeypatch.setattr(
             tox._quickstart, 'term_input', 
             self.get_mock_term_input(['4', '', '', '', '', '', '', '', '', '', '', '', '']))
         result = open('tox.ini').read()
         assert(result == expected_tox_ini)
 
-    def test_quickstart_main_existing_tox_ini(self, monkeypatch, tmpdir):
+    def test_quickstart_main_existing_tox_ini(self, monkeypatch):
         try:
             f = open('tox.ini', 'w')
             f.write('foo bar\n')
 
 
 class TestToxQuickstart(object):
-    def test_pytest(self, tmpdir):
+    def test_pytest(self):
         d = {
             'py24': True,
             'py25': True,
         # print(result)
         assert(result == expected_tox_ini)
 
-    def test_setup_py_test(self, tmpdir):
+    def test_setup_py_test(self):
         d = {
             'py26': True,
             'py27': True,
         # print(result)
         assert(result == expected_tox_ini)
 
-    def test_trial(self, tmpdir):
+    def test_trial(self):
         d = {
             'py27': True,
             'commands': 'trial',
         # print(result)
         assert(result == expected_tox_ini)
 
-    def test_nosetests(self, tmpdir):
+    def test_nosetests(self):
         d = {
             'py27': True,
             'py32': True,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.