summaryrefslogtreecommitdiff
path: root/distutils2/tests
diff options
context:
space:
mode:
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>2011-01-28 18:16:23 +0100
committerPierre-Yves David <pierre-yves.david@ens-lyon.org>2011-01-28 18:16:23 +0100
commitb3bf2373c1c2c510095f8fd04651bc49ae6fa22a (patch)
tree5b0dfe6f8f5fcf82b1cf0cac5895945705e7977a /distutils2/tests
parent7a47c2ee6fefa555bd728701e8bc7d389f4a1c2f (diff)
downloaddisutils2-b3bf2373c1c2c510095f8fd04651bc49ae6fa22a.tar.gz
[datafiles] add {opt1,opt2,opt3} options to glob
Diffstat (limited to 'distutils2/tests')
-rw-r--r--distutils2/tests/test_datafiles.py45
1 files changed, 37 insertions, 8 deletions
diff --git a/distutils2/tests/test_datafiles.py b/distutils2/tests/test_datafiles.py
index 2e36862..d05efd3 100644
--- a/distutils2/tests/test_datafiles.py
+++ b/distutils2/tests/test_datafiles.py
@@ -5,15 +5,13 @@ import sys
from StringIO import StringIO
from distutils2.tests import unittest, support, run_unittest
-from distutils2.datafiles import resources_dests
+from distutils2.datafiles import resources_dests, RICH_GLOB
import re
from os import path as osp
-SLASH = re.compile(r'(?<=[^\\])(?:\\{2})*/')
-
class DataFilesTestCase(support.TempdirManager,
support.LoggingCatcher,
unittest.TestCase):
@@ -23,20 +21,30 @@ class DataFilesTestCase(support.TempdirManager,
self.addCleanup(setattr, sys, 'stdout', sys.stdout)
self.addCleanup(setattr, sys, 'stderr', sys.stderr)
- def assertFindGlob(self, rules, spec):
+
+ def build_spec(self, spec, clean=True):
tempdir = self.mkdtemp()
for filepath in spec:
- filepath = osp.join(tempdir, *SLASH.split(filepath))
+ filepath = osp.join(tempdir, *filepath.split('/'))
dirname = osp.dirname(filepath)
if dirname and not osp.exists(dirname):
os.makedirs(dirname)
self.write_file(filepath, 'babar')
- for key, value in list(spec.items()):
- if value is None:
- del spec[key]
+ if clean:
+ for key, value in list(spec.items()):
+ if value is None:
+ del spec[key]
+ return tempdir
+
+ def assertFindGlob(self, rules, spec):
+ tempdir = self.build_spec(spec)
result = resources_dests(tempdir, rules)
self.assertEquals(spec, result)
+ def test_regex_rich_glob(self):
+ matches = RICH_GLOB.findall(r"babar aime les {fraises} est les {huitres}")
+ self.assertEquals(["fraises","huitres"], matches)
+
def test_simple_glob(self):
rules = [('', '*.tpl', '{data}')]
spec = {'coucou.tpl': '{data}/coucou.tpl',
@@ -50,6 +58,27 @@ class DataFilesTestCase(support.TempdirManager,
'Babarlikestrawberry': None}
self.assertFindGlob(rules, spec)
+ def test_set_match(self):
+ rules = [('scripts', '*.{bin,sh}', '{appscript}')]
+ spec = {'scripts/script.bin': '{appscript}/script.bin',
+ 'scripts/babar.sh': '{appscript}/babar.sh',
+ 'Babarlikestrawberry': None}
+ self.assertFindGlob(rules, spec)
+
+ def test_set_match_multiple(self):
+ rules = [('scripts', 'script{s,}.{bin,sh}', '{appscript}')]
+ spec = {'scripts/scripts.bin': '{appscript}/scripts.bin',
+ 'scripts/script.sh': '{appscript}/script.sh',
+ 'Babarlikestrawberry': None}
+ self.assertFindGlob(rules, spec)
+
+ def test_glob_in_base(self):
+ rules = [('scrip*', '*.bin', '{appscript}')]
+ spec = {'scripts/scripts.bin': '{appscript}/scripts.bin',
+ 'Babarlikestrawberry': None}
+ tempdir = self.build_spec(spec)
+ self.assertRaises(NotImplementedError, resources_dests, tempdir, rules)
+
def test_recursive_glob(self):
rules = [('', '**/*.bin', '{binary}')]
spec = {'binary0.bin': '{binary}/binary0.bin',