From 3ae24384c585cf3581394217961d4872ab0ce88b Mon Sep 17 00:00:00 2001 From: Florian Schulze Date: Fri, 20 Mar 2015 13:06:32 +0100 Subject: 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. --- tests/test_z_cmdline.py | 4 ++-- tox/_pytestplugin.py | 15 +++++++++------ 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: -- cgit v1.2.1