summaryrefslogtreecommitdiff
path: root/src/engine/SCons/Variables/VariablesTests.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-24 09:57:09 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-24 09:57:09 +0200
commitc7665433b2004d2b404d6fb9d6fd064998486f63 (patch)
tree8525ef6d24f7c6ceb238945ebb2cc997c7afc905 /src/engine/SCons/Variables/VariablesTests.py
parente48d2727885efda8369c7edbc2e3929a59532adc (diff)
parent6e228c305122f0564eda1e67d56651f8386d24d7 (diff)
Merge branch 'release/debian/3.1.0+repack-1'debian/3.1.0+repack-1
Diffstat (limited to 'src/engine/SCons/Variables/VariablesTests.py')
-rw-r--r--src/engine/SCons/Variables/VariablesTests.py44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/engine/SCons/Variables/VariablesTests.py b/src/engine/SCons/Variables/VariablesTests.py
index dc507ce..ed2edab 100644
--- a/src/engine/SCons/Variables/VariablesTests.py
+++ b/src/engine/SCons/Variables/VariablesTests.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2001 - 2017 The SCons Foundation
+# Copyright (c) 2001 - 2019 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,17 +21,17 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Variables/VariablesTests.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
+__revision__ = "src/engine/SCons/Variables/VariablesTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
import unittest
import TestSCons
-import TestUnit
import SCons.Variables
import SCons.Subst
import SCons.Warnings
+from SCons.Util import cmp
class Environment(object):
@@ -49,12 +49,6 @@ class Environment(object):
return key in self.dict
-def cmp(a, b):
- """
- Define cmp because it's no longer available in python3
- Works under python 2 as well
- """
- return (a > b) - (a < b)
def check(key, value, env):
@@ -65,7 +59,9 @@ def check(key, value, env):
def checkSave(file, expected):
gdict = {}
ldict = {}
- exec(open(file, 'r').read(), gdict, ldict)
+ with open(file, 'r') as f:
+ exec(f.read(), gdict, ldict)
+
assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict)
class VariablesTestCase(unittest.TestCase):
@@ -492,9 +488,29 @@ B: b - alpha test
default: 42
actual: 54
"""
+
+ expectBackwards = """
+B: b - alpha test
+ default: 42
+ actual: 54
+
+ANSWER: THE answer to THE question
+ default: 42
+ actual: 54
+
+A: a - alpha test
+ default: 42
+ actual: 54
+"""
text = opts.GenerateHelpText(env, sort=cmp)
assert text == expectAlpha, text
+ textBool = opts.GenerateHelpText(env, sort=True)
+ assert text == expectAlpha, text
+
+ textBackwards = opts.GenerateHelpText(env, sort=lambda x, y: cmp(y, x))
+ assert textBackwards == expectBackwards, "Expected:\n%s\nGot:\n%s\n"%(textBackwards, expectBackwards)
+
def test_FormatVariableHelpText(self):
"""Test generating custom format help text"""
opts = SCons.Variables.Variables()
@@ -675,13 +691,7 @@ class UnknownVariablesTestCase(unittest.TestCase):
if __name__ == "__main__":
- suite = unittest.TestSuite()
- tclasses = [ VariablesTestCase,
- UnknownVariablesTestCase ]
- for tclass in tclasses:
- names = unittest.getTestCaseNames(tclass, 'test_')
- suite.addTests(list(map(tclass, names)))
- TestUnit.run(suite)
+ unittest.main()
# Local Variables:
# tab-width:4