diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2020-03-08 14:49:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-08 14:49:23 +0200 |
commit | 44ff3e6c7de0db188284cc834b304e7b0e960d00 (patch) | |
tree | da5c45cecc16083c5120a3977383b42bd9d4cbf2 /run_unittests.py | |
parent | 91976a3489acbe53593e866fdb11951b515fda54 (diff) | |
parent | 06b1a317d26cbe2a1bd7a232dd9726590d0c0a48 (diff) | |
download | meson-44ff3e6c7de0db188284cc834b304e7b0e960d00.zip meson-44ff3e6c7de0db188284cc834b304e7b0e960d00.tar.gz meson-44ff3e6c7de0db188284cc834b304e7b0e960d00.tar.bz2 |
Merge pull request #6736 from dcbaker/mesonlib-type-annotations
Mesonlib type annotations
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/run_unittests.py b/run_unittests.py index e254d4a..c9b7563 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -686,12 +686,17 @@ class InternalTests(unittest.TestCase): self.assertEqual([holder1], listify([holder1])) self.assertEqual([holder1, 2], listify([holder1, 2])) self.assertEqual([holder1, 2, 3], listify([holder1, 2, [3]])) - self.assertEqual([1], listify(holder1, unholder=True)) - self.assertEqual([1], listify([holder1], unholder=True)) - self.assertEqual([1, 2], listify([holder1, 2], unholder=True)) - self.assertEqual([1, 2, 3], listify([holder1, 2, [holder3]], unholder=True)) - # Unholding doesn't work recursively when not flattening - self.assertEqual([1, [2], [holder3]], listify([holder1, [2], [holder3]], unholder=True, flatten=False)) + + def test_unholder(self): + unholder = mesonbuild.mesonlib.unholder + + holder1 = ObjectHolder(1) + holder3 = ObjectHolder(3) + holders = [holder1, holder3] + + self.assertEqual(1, unholder(holder1)) + self.assertEqual([1], unholder([holder1])) + self.assertEqual([1, 3], unholder(holders)) def test_extract_as_list(self): extract = mesonbuild.mesonlib.extract_as_list @@ -701,16 +706,15 @@ class InternalTests(unittest.TestCase): self.assertEqual(kwargs, {'sources': [1, 2, 3]}) self.assertEqual([1, 2, 3], extract(kwargs, 'sources', pop=True)) self.assertEqual(kwargs, {}) + # Test unholding holder3 = ObjectHolder(3) kwargs = {'sources': [1, 2, holder3]} - self.assertEqual([1, 2, 3], extract(kwargs, 'sources', unholder=True)) self.assertEqual(kwargs, {'sources': [1, 2, holder3]}) - self.assertEqual([1, 2, 3], extract(kwargs, 'sources', unholder=True, pop=True)) - self.assertEqual(kwargs, {}) - # Test listification - kwargs = {'sources': [1, 2, 3], 'pch_sources': [4, 5, 6]} - self.assertEqual([[1, 2, 3], [4, 5, 6]], extract(kwargs, 'sources', 'pch_sources')) + + # flatten nested lists + kwargs = {'sources': [1, [2, [3]]]} + self.assertEqual([1, 2, 3], extract(kwargs, 'sources')) def test_pkgconfig_module(self): |