aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-08-15 11:08:26 -0400
committerEli Schwartz <eschwartz@archlinux.org>2021-10-04 16:29:30 -0400
commite8a85fa8a2cdbbcd5dcefd9152be67e4416338ca (patch)
tree83ed77c6e7372b73fc7f84cb326fd95808335be8 /unittests
parent2d65472c725f18b343aee00bf91b9ac98c08b95f (diff)
downloadmeson-e8a85fa8a2cdbbcd5dcefd9152be67e4416338ca.zip
meson-e8a85fa8a2cdbbcd5dcefd9152be67e4416338ca.tar.gz
meson-e8a85fa8a2cdbbcd5dcefd9152be67e4416338ca.tar.bz2
various python neatness cleanups
All changes were created by running "pyupgrade --py3-only" and committing the results. Although this has been performed in the past, newer versions of pyupgrade can automatically catch more opportunities, notably list comprehensions can use generators instead, in the following cases: - unpacking into function arguments as function(*generator) - unpacking into assignments of the form x, y = generator - as the argument to some builtin functions such as min/max/sorted Also catch a few creeping cases of new code added using older styles.
Diffstat (limited to 'unittests')
-rw-r--r--unittests/allplatformstests.py4
-rw-r--r--unittests/datatests.py4
-rw-r--r--unittests/internaltests.py4
3 files changed, 6 insertions, 6 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 5ae33fe..707fc1d 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -1339,7 +1339,7 @@ class AllPlatformTests(BasePlatformTests):
tar = tarfile.open(xz_distfile, "r:xz") # [ignore encoding]
self.assertEqual(sorted(['samerepo-1.0',
'samerepo-1.0/meson.build']),
- sorted([i.name for i in tar]))
+ sorted(i.name for i in tar))
def test_rpath_uses_ORIGIN(self):
'''
@@ -2625,7 +2625,7 @@ class AllPlatformTests(BasePlatformTests):
def assertKeyTypes(key_type_list, obj, strict: bool = True):
for i in key_type_list:
if isinstance(i[1], (list, tuple)) and None in i[1]:
- i = (i[0], tuple([x for x in i[1] if x is not None]))
+ i = (i[0], tuple(x for x in i[1] if x is not None))
if i[0] not in obj or obj[i[0]] is None:
continue
self.assertIn(i[0], obj)
diff --git a/unittests/datatests.py b/unittests/datatests.py
index 6f4f421..b82ff1c 100644
--- a/unittests/datatests.py
+++ b/unittests/datatests.py
@@ -145,8 +145,8 @@ class DataTests(unittest.TestCase):
found_entries |= options
self.assertEqual(found_entries, {
- *[str(k) for k in mesonbuild.coredata.BUILTIN_OPTIONS],
- *[str(k) for k in mesonbuild.coredata.BUILTIN_OPTIONS_PER_MACHINE],
+ *(str(k) for k in mesonbuild.coredata.BUILTIN_OPTIONS),
+ *(str(k) for k in mesonbuild.coredata.BUILTIN_OPTIONS_PER_MACHINE),
})
# Check that `buildtype` table inside `Core options` matches how
diff --git a/unittests/internaltests.py b/unittests/internaltests.py
index a6f1ca5..957f180 100644
--- a/unittests/internaltests.py
+++ b/unittests/internaltests.py
@@ -509,8 +509,8 @@ class InternalTests(unittest.TestCase):
def _test_all_naming(self, cc, env, patterns, platform):
shr = patterns[platform]['shared']
stc = patterns[platform]['static']
- shrstc = shr + tuple([x for x in stc if x not in shr])
- stcshr = stc + tuple([x for x in shr if x not in stc])
+ shrstc = shr + tuple(x for x in stc if x not in shr)
+ stcshr = stc + tuple(x for x in shr if x not in stc)
p = cc.get_library_naming(env, LibType.SHARED)
self.assertEqual(p, shr)
p = cc.get_library_naming(env, LibType.STATIC)