diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-10-03 06:26:58 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-10-03 06:26:58 +0200 |
commit | 27b47b5db42407baf5d704bf52c35015b2c0ad7b (patch) | |
tree | 320f8d5fc315c211f7d073891bd7117754f5f5b3 /src/engine/SCons/EnvironmentTests.py | |
parent | 6be31f5d140b81227911cabfc61d3802c76c1b61 (diff) | |
parent | fabd454ddf505302bf41ef4da0609437c29d5605 (diff) |
Merge branch 'release/3.0.0+repack-1'3.0.0+repack-1
Diffstat (limited to 'src/engine/SCons/EnvironmentTests.py')
-rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 74 |
1 files changed, 35 insertions, 39 deletions
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 2aef997..70eda9e 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -21,7 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/EnvironmentTests.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" +from __future__ import print_function + +__revision__ = "src/engine/SCons/EnvironmentTests.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" import SCons.compat @@ -114,11 +116,11 @@ class Scanner(object): global scanned_it scanned_it[filename] = 1 - def __cmp__(self, other): + def __eq__(self, other): try: - return cmp(self.__dict__, other.__dict__) + return self.__dict__ == other.__dict__ except AttributeError: - return 1 + return False def get_skeys(self, env): return self.skeys @@ -245,7 +247,9 @@ class SubstitutionTestCase(unittest.TestCase): """ env = SubstitutionEnvironment(XXX = 'x', YYY = 'y') items = list(env.items()) - assert items == [('XXX','x'), ('YYY','y')], items + assert len(items) == 2 and ('XXX','x') in items and ('YYY','y') in items, items + # Was. This fails under py3 as order changes + # assert items == [('XXX','x'), ('YYY','y')], items def test_arg2nodes(self): """Test the arg2nodes method @@ -265,16 +269,10 @@ class SubstitutionTestCase(unittest.TestCase): assert isinstance(nodes[0], X) assert nodes[0].name == "Util.py UtilTests.py" - try: unicode - except NameError: pass - else: - code = """if 1: - nodes = env.arg2nodes(u"Util.py UtilTests.py", Factory) - assert len(nodes) == 1, nodes - assert isinstance(nodes[0], X) - assert nodes[0].name == u"Util.py UtilTests.py" - \n""" - exec code in globals(), locals() + nodes = env.arg2nodes(u"Util.py UtilTests.py", Factory) + assert len(nodes) == 1, nodes + assert isinstance(nodes[0], X) + assert nodes[0].name == u"Util.py UtilTests.py" nodes = env.arg2nodes(["Util.py", "UtilTests.py"], Factory) assert len(nodes) == 2, nodes @@ -657,7 +655,7 @@ sys.exit(0) cmd = '%s %s' % (python, test.workpath('fail.py')) try: env.backtick(cmd) - except OSError, e: + except OSError as e: assert str(e) == "'%s' exited 1" % cmd, str(e) else: self.fail("did not catch expected OSError") @@ -1463,8 +1461,6 @@ def exists(env): assert env['SOURCE'] == 's', env['SOURCE'] assert env['SOURCES'] == 'sss', env['SOURCES'] - - def test_Append(self): """Test appending to construction variables in an Environment """ @@ -1566,17 +1562,17 @@ def exists(env): env['XXX'] = copy.copy(input) try: env.Append(XXX = append) - except Exception, e: - if failed == 0: print - print " %s Append %s exception: %s" % \ - (repr(input), repr(append), e) + except Exception as e: + if failed == 0: print() + print(" %s Append %s exception: %s" % \ + (repr(input), repr(append), e)) failed = failed + 1 else: result = env['XXX'] if result != expect: - if failed == 0: print - print " %s Append %s => %s did not match %s" % \ - (repr(input), repr(append), repr(result), repr(expect)) + if failed == 0: print() + print(" %s Append %s => %s did not match %s" % \ + (repr(input), repr(append), repr(result), repr(expect))) failed = failed + 1 del cases[:3] assert failed == 0, "%d Append() cases failed" % failed @@ -1598,7 +1594,7 @@ def exists(env): self.name = name def __str__(self): return self.name - def __cmp__(self, other): + def __eq__(self, other): raise Exception("should not compare") ccc = C('ccc') @@ -1873,7 +1869,7 @@ def generate(env): # test for pull request #150 env = self.TestEnvironment() env._dict.pop('BUILDERS') - assert env.has_key('BUILDERS') is False + assert ('BUILDERS' in env) is False env2 = env.Clone() def test_Copy(self): @@ -1926,7 +1922,7 @@ def generate(env): assert x is None, x sub2_xxx_exe = test.workpath('sub2', 'xxx.exe') - os.chmod(sub2_xxx_exe, 0755) + os.chmod(sub2_xxx_exe, 0o755) env = self.TestEnvironment(ENV = { 'PATH' : [sub1, sub2] }) @@ -1934,7 +1930,7 @@ def generate(env): assert x == 'xxx.exe', x sub1_xxx_exe = test.workpath('sub1', 'xxx.exe') - os.chmod(sub1_xxx_exe, 0755) + os.chmod(sub1_xxx_exe, 0o755) x = env.Detect('xxx.exe') assert x == 'xxx.exe', x @@ -2252,17 +2248,17 @@ f5: \ env['XXX'] = copy.copy(input) try: env.Prepend(XXX = prepend) - except Exception, e: - if failed == 0: print - print " %s Prepend %s exception: %s" % \ - (repr(input), repr(prepend), e) + except Exception as e: + if failed == 0: print() + print(" %s Prepend %s exception: %s" % \ + (repr(input), repr(prepend), e)) failed = failed + 1 else: result = env['XXX'] if result != expect: - if failed == 0: print - print " %s Prepend %s => %s did not match %s" % \ - (repr(input), repr(prepend), repr(result), repr(expect)) + if failed == 0: print() + print(" %s Prepend %s => %s did not match %s" % \ + (repr(input), repr(prepend), repr(result), repr(expect))) failed = failed + 1 del cases[:3] assert failed == 0, "%d Prepend() cases failed" % failed @@ -2500,10 +2496,10 @@ def generate(env): os.mkdir(sub2_xxx_exe) test.write(sub3_xxx_exe, "\n") - os.chmod(sub3_xxx_exe, 0777) + os.chmod(sub3_xxx_exe, 0o777) test.write(sub4_xxx_exe, "\n") - os.chmod(sub4_xxx_exe, 0777) + os.chmod(sub4_xxx_exe, 0o777) env_path = os.environ['PATH'] |