summaryrefslogtreecommitdiff
path: root/src/distutils2
diff options
context:
space:
mode:
authorErik Rose <ErikRose@psu.edu>2010-02-24 18:02:10 -0500
committerErik Rose <ErikRose@psu.edu>2010-02-24 18:02:10 -0500
commit54b40b047e3e74516ef6a587603783ace07b42b5 (patch)
tree90493b903d9cbffb5c8ae74f56aea267d07ba15d /src/distutils2
parentcdfb94461f712c09bdb86d91baed26c4dec3b911 (diff)
downloaddisutils2-54b40b047e3e74516ef6a587603783ace07b42b5.tar.gz
Added a test to nail down the {token} substitution spec a tad. Added a docstring to describe the purpose of the _backport dir.
Diffstat (limited to 'src/distutils2')
-rw-r--r--src/distutils2/_backport/__init__.py2
-rw-r--r--src/distutils2/_backport/sysconfig.py6
-rw-r--r--src/distutils2/_backport/tests/test_sysconfig.py6
3 files changed, 12 insertions, 2 deletions
diff --git a/src/distutils2/_backport/__init__.py b/src/distutils2/_backport/__init__.py
index e69de29..c5227d3 100644
--- a/src/distutils2/_backport/__init__.py
+++ b/src/distutils2/_backport/__init__.py
@@ -0,0 +1,2 @@
+"""Things that will land in the Python 3.3 std lib but which we must drag along
+with us for now to support 2.x."""
diff --git a/src/distutils2/_backport/sysconfig.py b/src/distutils2/_backport/sysconfig.py
index f72ef5c..62ff8ca 100644
--- a/src/distutils2/_backport/sysconfig.py
+++ b/src/distutils2/_backport/sysconfig.py
@@ -75,7 +75,11 @@ if _PYTHON_BUILD:
def _subst_vars(path, local_vars):
- # simple curly-braces replacement
+ """In the string `path`, replace tokens like {some.thing} with the corresponding value from the map `local_vars`.
+
+ If there is no corresponding value, leave the token unchanged.
+
+ """
def _replacer(matchobj):
name = matchobj.group(1)
if name in local_vars:
diff --git a/src/distutils2/_backport/tests/test_sysconfig.py b/src/distutils2/_backport/tests/test_sysconfig.py
index 5bc98cf..294ed5c 100644
--- a/src/distutils2/_backport/tests/test_sysconfig.py
+++ b/src/distutils2/_backport/tests/test_sysconfig.py
@@ -17,7 +17,7 @@ import distutils2._backport.sysconfig
from distutils2._backport.sysconfig import (get_paths, get_platform,
get_config_vars, _expand_globals,
get_path, get_path_names,
- _get_default_scheme, _expand_vars,
+ _get_default_scheme, _subst_vars, _expand_vars,
get_scheme_names, _CONFIG_FILE)
class TestSysConfig(unittest2.TestCase):
@@ -87,6 +87,10 @@ class TestSysConfig(unittest2.TestCase):
elif os.path.isdir(path):
shutil.rmtree(path)
+ def test_var_expansion_pattern(self):
+ """Assert that the {curly brace token} expansion pattern counts the second { as part of the substitution key in expressions like {{something}."""
+ self.failUnlessEqual(_subst_vars('thing{{stuffvar}', {'{stuffvar': 'stuff'}), 'thingstuff')
+
def test_get_paths(self):
scheme = get_paths()
default_scheme = _get_default_scheme()