aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2017-04-18 21:00:50 -0500
committerJason R. Coombs <jaraco@jaraco.com>2017-04-18 23:58:21 -0400
commitd8e1ed570126dfc99ed7f9126df3bfc890e7005d (patch)
tree0467889d17d9659c2cb07b209fcefcf8bbc22372
parentf1a9711815acab7e2d9c77b86b43117f72c5c78f (diff)
downloadexternal_python_setuptools-d8e1ed570126dfc99ed7f9126df3bfc890e7005d.tar.gz
external_python_setuptools-d8e1ed570126dfc99ed7f9126df3bfc890e7005d.tar.bz2
external_python_setuptools-d8e1ed570126dfc99ed7f9126df3bfc890e7005d.zip
Rewrite tests to test the actual matching rather than making assertions about the regular expressions. Fixes #1015.
-rw-r--r--.travis.yml3
-rw-r--r--setuptools/tests/test_manifest.py103
2 files changed, 83 insertions, 23 deletions
diff --git a/.travis.yml b/.travis.yml
index fd18a33a..adb2f948 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,9 +14,6 @@ matrix:
env: LC_ALL=C LC_CTYPE=C
- python: 2.7
env: LC_ALL=C LC_CTYPE=C
- allow_failures:
- # https://github.com/pypa/setuptools/issues/1015
- - python: nightly
script:
# need tox and rwt to get started
- pip install tox rwt
diff --git a/setuptools/tests/test_manifest.py b/setuptools/tests/test_manifest.py
index 57347b53..28cbca1a 100644
--- a/setuptools/tests/test_manifest.py
+++ b/setuptools/tests/test_manifest.py
@@ -6,6 +6,7 @@ import os
import shutil
import sys
import tempfile
+import itertools
from distutils import log
from distutils.errors import DistutilsTemplateError
@@ -65,32 +66,94 @@ default_files = frozenset(map(make_local_path, [
]))
-def get_pattern(glob):
- return translate_pattern(make_local_path(glob)).pattern
-
-
-def test_translated_pattern_test():
- l = make_local_path
- assert get_pattern('foo') == r'foo\Z'
- assert get_pattern(l('foo/bar')) == l(r'foo\/bar\Z')
+translate_specs = [
+ ('foo', ['foo'], ['bar', 'foobar']),
+ ('foo/bar', ['foo/bar'], ['foo/bar/baz', './foo/bar', 'foo']),
# Glob matching
- assert get_pattern('*.txt') == l(r'[^\/]*\.txt\Z')
- assert get_pattern('dir/*.txt') == l(r'dir\/[^\/]*\.txt\Z')
- assert get_pattern('*/*.py') == l(r'[^\/]*\/[^\/]*\.py\Z')
- assert get_pattern('docs/page-?.txt') \
- == l(r'docs\/page\-[^\/]\.txt\Z')
+ ('*.txt', ['foo.txt', 'bar.txt'], ['foo/foo.txt']),
+ ('dir/*.txt', ['dir/foo.txt', 'dir/bar.txt', 'dir/.txt'], ['notdir/foo.txt']),
+ ('*/*.py', ['bin/start.py'], []),
+ ('docs/page-?.txt', ['docs/page-9.txt'], ['docs/page-10.txt']),
# Globstars change what they mean depending upon where they are
- assert get_pattern(l('foo/**/bar')) == l(r'foo\/(?:[^\/]+\/)*bar\Z')
- assert get_pattern(l('foo/**')) == l(r'foo\/.*\Z')
- assert get_pattern(l('**')) == r'.*\Z'
+ (
+ 'foo/**/bar',
+ ['foo/bing/bar', 'foo/bing/bang/bar', 'foo/bar'],
+ ['foo/abar'],
+ ),
+ (
+ 'foo/**',
+ ['foo/bar/bing.py', 'foo/x'],
+ ['/foo/x'],
+ ),
+ (
+ '**',
+ ['x', 'abc/xyz', '@nything'],
+ [],
+ ),
# Character classes
- assert get_pattern('pre[one]post') == r'pre[one]post\Z'
- assert get_pattern('hello[!one]world') == r'hello[^one]world\Z'
- assert get_pattern('[]one].txt') == r'[\]one]\.txt\Z'
- assert get_pattern('foo[!]one]bar') == r'foo[^\]one]bar\Z'
+ (
+ 'pre[one]post',
+ ['preopost', 'prenpost', 'preepost'],
+ ['prepost', 'preonepost'],
+ ),
+
+ (
+ 'hello[!one]world',
+ ['helloxworld', 'helloyworld'],
+ ['hellooworld', 'helloworld', 'hellooneworld'],
+ ),
+
+ (
+ '[]one].txt',
+ ['o.txt', '].txt', 'e.txt'],
+ ['one].txt'],
+ ),
+
+ (
+ 'foo[!]one]bar',
+ ['fooybar'],
+ ['foo]bar', 'fooobar', 'fooebar'],
+ ),
+
+]
+"""
+A spec of inputs for 'translate_pattern' and matches and mismatches
+for that input.
+"""
+
+match_params = itertools.chain.from_iterable(
+ zip(itertools.repeat(pattern), matches)
+ for pattern, matches, mismatches in translate_specs
+)
+
+
+@pytest.fixture(params=match_params)
+def pattern_match(request):
+ return map(make_local_path, request.param)
+
+
+mismatch_params = itertools.chain.from_iterable(
+ zip(itertools.repeat(pattern), mismatches)
+ for pattern, matches, mismatches in translate_specs
+)
+
+
+@pytest.fixture(params=mismatch_params)
+def pattern_mismatch(request):
+ return map(make_local_path, request.param)
+
+
+def test_translated_pattern_match(pattern_match):
+ pattern, target = pattern_match
+ assert translate_pattern(pattern).match(target)
+
+
+def test_translated_pattern_mismatch(pattern_mismatch):
+ pattern, target = pattern_mismatch
+ assert not translate_pattern(pattern).match(target)
class TempDirTestCase(object):