diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-03-02 11:11:17 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-03-05 09:31:29 -0800 |
commit | a8293dd59c0a22817f2336df8ae97dce1232f72a (patch) | |
tree | 123b316ad1bf34c52f75c29d05e8b94ab05d52be /run_unittests.py | |
parent | 1a82880730e2d9f58eaa67179aa40c6976835278 (diff) | |
download | meson-a8293dd59c0a22817f2336df8ae97dce1232f72a.zip meson-a8293dd59c0a22817f2336df8ae97dce1232f72a.tar.gz meson-a8293dd59c0a22817f2336df8ae97dce1232f72a.tar.bz2 |
mesonlib: Replace unholder argument to listify
listify shouldn't be unholdering, it's a function to turn scalar values
into lists, or flatten lists. Having a separate function is clearer,
easier to understand, and can be run recursively if necessary.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/run_unittests.py b/run_unittests.py index 658da37..b39ba28 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 @@ -704,14 +709,15 @@ class InternalTests(unittest.TestCase): # 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', flatten=True)) + def test_pkgconfig_module(self): class Mock: |