summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGaurav Juvekar <gauravjuvekar@gmail.com>2017-04-07 08:09:33 (GMT)
committerGaurav Juvekar <gauravjuvekar@gmail.com>2017-04-07 08:09:33 (GMT)
commitec5cfb99fa60afc33a52bf231f16d44d1f9a0074 (patch)
tree28345e2916a1c03caab2b940b3ca69ee925f2a76
parentcce4024322a5433d441a0d9058c9a1950590ae0c (diff)
downloadSCons-ec5cfb99fa60afc33a52bf231f16d44d1f9a0074.zip
SCons-ec5cfb99fa60afc33a52bf231f16d44d1f9a0074.tar.gz
SCons-ec5cfb99fa60afc33a52bf231f16d44d1f9a0074.tar.bz2
py2/3 fixes for CPPDEFINES/append.py test case
-rw-r--r--test/CPPDEFINES/append.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/test/CPPDEFINES/append.py b/test/CPPDEFINES/append.py
index 14ea7b3..04a2d7b 100644
--- a/test/CPPDEFINES/append.py
+++ b/test/CPPDEFINES/append.py
@@ -52,12 +52,28 @@ env_2300_2 = Environment(CPPDEFINES = ['foo'], CPPDEFPREFIX='-D') # note the lis
env_2300_2.Append(CPPDEFINES='bar')
print(env_2300_2.subst('$_CPPDEFFLAGS'))
+
+# Python3 dicts dont preserve order. Hence we supply subclass of OrderedDict
+# whose __str__ and __repr__ act like a normal dict.
+from collections import OrderedDict
+class OrderedPrintingDict(OrderedDict):
+ def __str__(self):
+ return '{' + ', '.join(['%r: %r'%(k, v) for (k, v) in self.items()]) + '}'
+
+ def __repr__(self):
+ return '{' + ', '.join(['%r: %r'%(k, v) for (k, v) in self.items()]) + '}'
+
+ def __semi_deepcopy__(self):
+ # Because a dict subclass is not deep copied directly when constructing
+ # Environment(CPPDEFINES = OrderedPrintingDict(...))
+ return self.copy()
+
# http://scons.tigris.org/issues/show_bug.cgi?id=1152
# http://scons.tigris.org/issues/show_bug.cgi?id=2900
cases=[('string', 'FOO'),
('list', ['NAME1', 'NAME2']),
('list-of-2lists', [('NAME1','VAL1'), ['NAME2','VAL2']]),
- ('dict', {'NAME1' : 'VAL1', 'NAME2' : 'VAL2', 'NAME3' : None})
+ ('dict', OrderedPrintingDict([('NAME2', 'VAL2'), ('NAME3', None), ('NAME1', 'VAL1')]))
]
for (t1, c1) in cases:
@@ -180,7 +196,7 @@ AppendUnique:
==== Testing CPPDEFINES, appending a string to a dict
orig = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}, append = FOO
Append:
- result={'FOO': None, 'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}
+ result={'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1', 'FOO': None}
final=-DFOO -DNAME1=VAL1 -DNAME2=VAL2 -DNAME3
AppendUnique:
result=[('NAME2', 'VAL2'), ('NAME3',), ('NAME1', 'VAL1'), 'FOO']