summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Schulze <florian.schulze@gmx.net>2015-03-20 13:06:32 +0100
committerFlorian Schulze <florian.schulze@gmx.net>2015-03-20 13:06:32 +0100
commit3ae24384c585cf3581394217961d4872ab0ce88b (patch)
tree699c3fa515cdbf1957124d75d68edd7c5168e99f
parent6ff5133b63a7fe369f8f023dfde652fbf3d3c9ad (diff)
downloadtox-3ae24384c585cf3581394217961d4872ab0ce88b.tar.gz
Enhanced initproj fixture to accept a tuple for name/version specifier.
This allows projects with dashes in their name. This fixture is used in devpi where this functionality is needed.
-rw-r--r--tests/test_z_cmdline.py4
-rw-r--r--tox/_pytestplugin.py15
2 files changed, 11 insertions, 8 deletions
diff --git a/tests/test_z_cmdline.py b/tests/test_z_cmdline.py
index 00188ac..0c145be 100644
--- a/tests/test_z_cmdline.py
+++ b/tests/test_z_cmdline.py
@@ -598,7 +598,7 @@ def test_sdistonly(initproj, cmd):
def test_separate_sdist_no_sdistfile(cmd, initproj):
distshare = cmd.tmpdir.join("distshare")
- initproj("pkg123-0.7", filedefs={
+ initproj(("pkg123-foo", "0.7"), filedefs={
'tox.ini': """
[tox]
distshare=%s
@@ -609,7 +609,7 @@ def test_separate_sdist_no_sdistfile(cmd, initproj):
l = distshare.listdir()
assert len(l) == 1
sdistfile = l[0]
- assert 'pkg123-0.7.zip' in str(sdistfile)
+ assert 'pkg123-foo-0.7.zip' in str(sdistfile)
def test_separate_sdist(cmd, initproj):
distshare = cmd.tmpdir.join("distshare")
diff --git a/tox/_pytestplugin.py b/tox/_pytestplugin.py
index 4f00d3f..ded13ec 100644
--- a/tox/_pytestplugin.py
+++ b/tox/_pytestplugin.py
@@ -2,7 +2,7 @@ import pytest, py
import tox
import os
import sys
-from py.builtin import print_
+from py.builtin import _isbytes, _istext, print_
from fnmatch import fnmatch
import time
from tox._config import parseconfig
@@ -263,13 +263,16 @@ class LineMatcher:
@pytest.fixture
def initproj(request, tmpdir):
""" create a factory function for creating example projects. """
- def initproj(name, filedefs=None):
+ def initproj(nameversion, filedefs=None):
if filedefs is None:
filedefs = {}
- parts = name.split("-")
- if len(parts) == 1:
- parts.append("0.1")
- name, version = parts
+ if _istext(nameversion) or _isbytes(nameversion):
+ parts = nameversion.split("-")
+ if len(parts) == 1:
+ parts.append("0.1")
+ name, version = parts
+ else:
+ name, version = nameversion
base = tmpdir.ensure(name, dir=1)
create_files(base, filedefs)
if 'setup.py' not in filedefs: