diff options
author | Marc Abramowitz <marc@marc-abramowitz.com> | 2012-11-22 11:06:21 -0800 |
---|---|---|
committer | Marc Abramowitz <marc@marc-abramowitz.com> | 2012-11-22 11:06:21 -0800 |
commit | c915f34ad1d76519924352113e052ed2ca65f645 (patch) | |
tree | d76fa335842f5d8ddd6ff618711026e5c468bd56 /tests | |
parent | da5d8a57e9c06c3c5331be9049eed4e500b28e16 (diff) | |
parent | 7321d1d133b15367538510ae568e520cdd2bd2a9 (diff) | |
download | tox-git-c915f34ad1d76519924352113e052ed2ca65f645.tar.gz |
Update my fork; merge from ssh://hg@bitbucket.org/hpk42/tox
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conftest.py | 3 | ||||
-rw-r--r-- | tests/test_config.py | 29 | ||||
-rw-r--r-- | tests/test_venv.py | 11 |
3 files changed, 31 insertions, 12 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 51bc0a22..2f330226 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -106,7 +106,8 @@ class ReportExpectMock: class pcallMock: def __init__(self, args, cwd, env, stdout, stderr, shell): - self.args = args + self.arg0 = args[0] + self.args = args[1:] self.cwd = cwd self.env = env self.stdout = stdout diff --git a/tests/test_config.py b/tests/test_config.py index 9ad8398e..68ba6094 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -4,6 +4,7 @@ from textwrap import dedent import py from tox._config import IniReader, CommandParser +from tox._config import parseconfig class TestVenvConfig: def test_config_parsing_minimal(self, tmpdir, newconfig): @@ -73,6 +74,17 @@ class TestConfigPackage: """ % tmpdir) assert config.toxworkdir == tmpdir +class TestParseconfig: + def test_search_parents(self, tmpdir): + b = tmpdir.mkdir("a").mkdir("b") + toxinipath = tmpdir.ensure("tox.ini") + old = b.chdir() + try: + config = parseconfig([]) + finally: + old.chdir() + assert config.toxinipath == toxinipath + class TestIniParser: def test_getdefault_single(self, tmpdir, newconfig): config = newconfig(""" @@ -429,7 +441,7 @@ class TestConfigTestEnv: assert argv[3][0] == conf.envbindir assert argv[4][0] == conf.envtmpdir assert argv[5][0] == conf.envpython - assert argv[6][0] == os.path.expanduser("~") + assert argv[6][0] == str(py.path.local._gethomedir()) assert argv[7][0] == config.homedir.join(".tox", "distshare") assert argv[8][0] == conf.envlogdir @@ -655,6 +667,11 @@ class TestGlobalOptions: config = newconfig(["-eALL"], inisource) assert config.envlist == ['py26', 'py27', 'py31'] + def test_py_venv(self, tmpdir, newconfig, monkeypatch): + config = newconfig(["-epy"], "") + env = config.envconfigs['py'] + assert str(env.basepython) == sys.executable + def test_default_environments(self, tmpdir, newconfig, monkeypatch): envs = "py24,py25,py26,py27,py30,py31,py32,jython,pypy" inisource = """ @@ -763,13 +780,6 @@ class TestCmdInvocation: assert tox.__version__ in stdout assert "imported from" in stdout - def test_unkonwn_ini(self, cmd): - result = cmd.run("tox") - assert result.ret - result.stderr.fnmatch_lines([ - "*tox.ini*does not exist*", - ]) - @py.test.mark.xfail("sys.version_info < (2,6)", reason="virtualenv3 cannot be imported") def test_config_specific_ini(self, tmpdir, cmd): @@ -785,10 +795,9 @@ class TestCmdInvocation: result = cmd.run("tox") assert result.ret result.stderr.fnmatch_lines([ - "*ERROR*tox.ini*does not exist*", + "*ERROR*tox.ini*not*found*", ]) - class TestCommandParser: def test_command_parser_for_word(self): diff --git a/tests/test_venv.py b/tests/test_venv.py index 98cb94cd..4fa0ad0e 100644 --- a/tests/test_venv.py +++ b/tests/test_venv.py @@ -3,6 +3,7 @@ import tox import pytest import os, sys from tox._venv import VirtualEnv, CreationConfig, getdigest +from tox._venv import find_executable #def test_global_virtualenv(capfd): # v = VirtualEnv() @@ -15,6 +16,7 @@ from tox._venv import VirtualEnv, CreationConfig, getdigest def test_getdigest(tmpdir): assert getdigest(tmpdir) == "0"*32 +@pytest.mark.skipif("sys.platform != 'win32'") def test_locate_via_py(monkeypatch): from tox._venv import locate_via_py class PseudoPy: @@ -31,7 +33,6 @@ def test_locate_via_py(monkeypatch): assert locate_via_py('3', '2') == sys.executable def test_find_executable(): - from tox._venv import find_executable p = find_executable(sys.executable) assert p == py.path.local(sys.executable) for ver in [""] + "2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3".split(): @@ -52,6 +53,14 @@ def test_find_executable(): stdout, stderr = popen.communicate() assert ver in py.builtin._totext(stderr, "ascii") +def test_find_executable_extra(monkeypatch): + @staticmethod + def sysfind(x): + return "hello" + monkeypatch.setattr(py.path.local, "sysfind", sysfind) + t = find_executable("qweqwe") + assert t == "hello" + def test_getsupportedinterpreter(monkeypatch, newconfig, mocksession): config = newconfig([], """ [testenv:python] |