aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-06-04 10:52:15 -0700
committerDaniel Mensinger <daniel@mensinger-ka.de>2021-06-08 11:00:55 +0200
commit6ab78b5979afb3347eca0da1a8000aee3a443cb9 (patch)
treedf12d629724f6c7fb22448773325807011fb9f5b /run_unittests.py
parentfb385728df5d14c929420c6fd0fb2958f274761d (diff)
downloadmeson-6ab78b5979afb3347eca0da1a8000aee3a443cb9.zip
meson-6ab78b5979afb3347eca0da1a8000aee3a443cb9.tar.gz
meson-6ab78b5979afb3347eca0da1a8000aee3a443cb9.tar.bz2
intperperterbase: Add a convertor keyword argument
This is meant to allow simple type conversions to happen before the interpreter function is called. This should simplify some cases like the "native" keyword arugment that are booleans in the Meson DSL, but an Enum in the implementation
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 9f66d9c..21bb30e 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1644,6 +1644,16 @@ class InternalTests(unittest.TestCase):
_(None, mock.Mock(), tuple(), dict(input='bar'))
self.assertEqual(str(cm.exception), "testfunc keyword argument \"input\" invalid!")
+ def test_typed_kwarg_convertor(self) -> None:
+ @typed_kwargs(
+ 'testfunc',
+ KwargInfo('native', bool, convertor=lambda n: MachineChoice.BUILD if n else MachineChoice.HOST)
+ )
+ def _(obj, node, args: T.Tuple, kwargs: T.Dict[str, MachineChoice]) -> None:
+ assert isinstance(kwargs['native'], MachineChoice)
+
+ _(None, mock.Mock(), tuple(), dict(native=True))
+
@unittest.skipIf(is_tarball(), 'Skipping because this is a tarball release')
class DataTests(unittest.TestCase):