Files
xahaud/python/beast/util/Dict_test.py
Tom Ritchford 6b0cec1189 Improvements to scons build for beast.
* Common code extracted to Python directories.
* Read ~/.scons file for scons environment defaults.
* Override scons settings with shell environment variables.
* New "tags" for debug, nodebug, optimize, nooptimize builds.
* Universal platform detection.
* Default value of environment variables set through prefix dictionaries.
* Check for correct Boost value and fail otherwise.
* Extract git describe --tags into a preprocesor variable, -DTIP_BRANCH
* More colors - blue for unchanged defaults, green for changed defaults, red for error.
* Contain unit tests for non-obvious stuff.
* Check to see that boost libraries have been built.
* Right now, we accept both .dylib and .a versions but it'd be easy to enforce .a only.
2014-04-11 10:40:26 -07:00

57 lines
1.5 KiB
Python

from __future__ import absolute_import, division, print_function, unicode_literals
from unittest import TestCase
from beast.util import Dict
DICT = {
'': {
'foo': 'foo-default',
'bar': 'bar-default',
},
'Darwin': {
'foo': 'foo-darwin',
'baz': 'baz-darwin',
},
'Darwin.10.8': {
'foo': 'foo-darwin-10.8',
'bing': 'bing-darwin-10.8',
},
}
class test_Dict(TestCase):
def computeMapValue(self, config, key):
return Dict.compose(*Dict.get_items_with_prefix(config, DICT))[key]
def assertMapValue(self, config, key, result):
self.assertEquals(self.computeMapValue(config, key), result)
def testDefault1(self):
self.assertMapValue('', 'foo', 'foo-default')
def testDefault2(self):
self.assertMapValue('Darwin.10.8', 'bar', 'bar-default')
def testPrefix1(self):
self.assertMapValue('Darwin', 'foo', 'foo-darwin')
def testPrefix2(self):
self.assertMapValue('Darwin.10.8', 'foo', 'foo-darwin-10.8')
def testPrefix3(self):
self.assertMapValue('Darwin', 'baz', 'baz-darwin')
def testPrefix4(self):
self.assertMapValue('Darwin.10.8', 'bing', 'bing-darwin-10.8')
def testFailure1(self):
self.assertRaises(KeyError, self.computeMapValue, '', 'baz')
def testFailure2(self):
self.assertRaises(KeyError, self.computeMapValue, '', 'bing')
def testFailure2(self):
self.assertRaises(KeyError, self.computeMapValue, 'Darwin', 'bing')