def test_defaults(self):
        test = ReadOnlyKeyedDefaultDict(lambda x: x, {'foo': 1})

        self.assertEqual(test['foo'], 1)

        self.assertEqual(test['qux'], 'qux')

        self.assertEqual(test['bar'], 'bar')

        copy = dict(test)

        with self.assertRaises(Exception):
            test['foo'] = 2

        with self.assertRaises(Exception):
            test['qux'] = None

        with self.assertRaises(Exception):
            test['baz'] = 'foo'

        self.assertEqual(test, copy)

        self.assertEqual(len(test), 3)
Exemple #2
0
    def test_defaults(self):
        test = ReadOnlyKeyedDefaultDict(lambda x: x, {"foo": 1})

        self.assertEqual(test["foo"], 1)

        self.assertEqual(test["qux"], "qux")

        self.assertEqual(test["bar"], "bar")

        copy = dict(test)

        with self.assertRaises(Exception):
            test["foo"] = 2

        with self.assertRaises(Exception):
            test["qux"] = None

        with self.assertRaises(Exception):
            test["baz"] = "foo"

        self.assertEqual(test, copy)

        self.assertEqual(len(test), 3)
Exemple #3
0
        The relative path is from ``TOPSRCDIR``. This is defined as relative
        to the main file being executed, regardless of whether additional
        files have been included using ``include()``.
        """),
    'SRCDIR': (lambda context: context.srcdir, str,
               """Constant defining the source directory of this file.

        This is the path inside ``TOPSRCDIR`` where this file is located. It
        is the same as ``TOPSRCDIR + RELATIVEDIR``.
        """),
    'OBJDIR': (lambda context: context.objdir, str,
               """The path to the object directory for this file.

        Is is the same as ``TOPOBJDIR + RELATIVEDIR``.
        """),
    'CONFIG': (lambda context: ReadOnlyKeyedDefaultDict(
        lambda key: context.config.substs_unicode.get(key)), dict,
               """Dictionary containing the current configuration variables.

        All the variables defined by the configuration system are available
        through this object. e.g. ``ENABLE_TESTS``, ``CFLAGS``, etc.

        Values in this container are read-only. Attempts at changing values
        will result in a run-time error.

        Access to an unknown variable will return None.
        """),
}

# Deprecation hints.
DEPRECATION_HINTS = {
    'TOOL_DIRS': 'Please use the DIRS variable instead.',