diff options
author | Steven Knight <knight@baldmt.com> | 2004-03-31 13:09:38 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-03-31 13:09:38 (GMT) |
commit | c56e4cfbc03b9177b258c726e3254e79dbbd2dc5 (patch) | |
tree | b49940bbd5ce49ce9b5a214fa2b8b2a0be447c77 /src/engine/SCons/EnvironmentTests.py | |
parent | 67b6df08052c27473b85bfe5c7a39b3f730573ea (diff) | |
download | SCons-c56e4cfbc03b9177b258c726e3254e79dbbd2dc5.zip SCons-c56e4cfbc03b9177b258c726e3254e79dbbd2dc5.tar.gz SCons-c56e4cfbc03b9177b258c726e3254e79dbbd2dc5.tar.bz2 |
Fix the Command() global function when the action is a command-line string.
Diffstat (limited to 'src/engine/SCons/EnvironmentTests.py')
-rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 97 |
1 files changed, 95 insertions, 2 deletions
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 8d1c3f3..de313b4 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -2352,7 +2352,100 @@ class EnvironmentTestCase(unittest.TestCase): assert f == 'foo', f + +class NoSubstitutionProxyTestCase(unittest.TestCase): + + def test___init__(self): + """Test NoSubstitutionProxy initialization""" + env = Environment(XXX = 'x', YYY = 'y') + assert env['XXX'] == 'x', env['XXX'] + assert env['YYY'] == 'y', env['YYY'] + + proxy = NoSubstitutionProxy(env) + assert proxy['XXX'] == 'x', proxy['XXX'] + assert proxy['YYY'] == 'y', proxy['YYY'] + + def test_attributes(self): + """Test getting and setting NoSubstitutionProxy attributes""" + env = Environment() + setattr(env, 'env_attr', 'value1') + + proxy = NoSubstitutionProxy(env) + setattr(proxy, 'proxy_attr', 'value2') + + x = getattr(env, 'env_attr') + assert x == 'value1', x + x = getattr(proxy, 'env_attr') + assert x == 'value1', x + + x = getattr(env, 'proxy_attr') + assert x == 'value2', x + x = getattr(proxy, 'proxy_attr') + assert x == 'value2', x + + def test_subst(self): + """Test the NoSubstitutionProxy.subst() method""" + env = Environment(XXX = 'x', YYY = 'y') + assert env['XXX'] == 'x', env['XXX'] + assert env['YYY'] == 'y', env['YYY'] + + proxy = NoSubstitutionProxy(env) + assert proxy['XXX'] == 'x', proxy['XXX'] + assert proxy['YYY'] == 'y', proxy['YYY'] + + x = env.subst('$XXX') + assert x == 'x', x + x = proxy.subst('$XXX') + assert x == '$XXX', x + + x = proxy.subst('$YYY', raw=7, target=None, source=None, + dict=None, conv=None, + extra_meaningless_keyword_argument=None) + assert x == '$YYY', x + + def test_subst_kw(self): + """Test the NoSubstitutionProxy.subst_kw() method""" + env = Environment(XXX = 'x', YYY = 'y') + assert env['XXX'] == 'x', env['XXX'] + assert env['YYY'] == 'y', env['YYY'] + + proxy = NoSubstitutionProxy(env) + assert proxy['XXX'] == 'x', proxy['XXX'] + assert proxy['YYY'] == 'y', proxy['YYY'] + + x = env.subst_kw({'$XXX':'$YYY'}) + assert x == {'x':'y'}, x + x = proxy.subst_kw({'$XXX':'$YYY'}) + assert x == {'$XXX':'$YYY'}, x + + def test_subst_list(self): + """Test the NoSubstitutionProxy.subst_list() method""" + env = Environment(XXX = 'x', YYY = 'y') + assert env['XXX'] == 'x', env['XXX'] + assert env['YYY'] == 'y', env['YYY'] + + proxy = NoSubstitutionProxy(env) + assert proxy['XXX'] == 'x', proxy['XXX'] + assert proxy['YYY'] == 'y', proxy['YYY'] + + x = env.subst_list('$XXX') + assert x == [['x']], x + x = proxy.subst_list('$XXX') + assert x == [['$XXX']], x + + x = proxy.subst_list('$YYY', raw=7, target=None, source=None, + dict=None, conv=None, + extra_meaningless_keyword_argument=None) + assert x == [['$YYY']], x + + + if __name__ == "__main__": - suite = unittest.makeSuite(EnvironmentTestCase, 'test_') + suite = unittest.TestSuite() + tclasses = [ EnvironmentTestCase, + NoSubstitutionProxyTestCase ] + for tclass in tclasses: + names = unittest.getTestCaseNames(tclass, 'test_') + suite.addTests(map(tclass, names)) if not unittest.TextTestRunner().run(suite).wasSuccessful(): - sys.exit(1) + sys.exit(1) |