Small refactoring of with usage in tests
This commit is contained in:
parent
1ee4361bdd
commit
b71e8a4a55
1 changed files with 31 additions and 37 deletions
16
mpv-test.py
16
mpv-test.py
|
|
@ -62,10 +62,8 @@ class TestProperties(unittest.TestCase):
|
||||||
for name, (ptype, access, *_args) in sorted(mpv.ALL_PROPERTIES.items()):
|
for name, (ptype, access, *_args) in sorted(mpv.ALL_PROPERTIES.items()):
|
||||||
if 'r' in access:
|
if 'r' in access:
|
||||||
name = name.replace('-', '_')
|
name = name.replace('-', '_')
|
||||||
with self.subTest(property_name=name):
|
with self.subTest(property_name=name), self.swallow_mpv_errors([
|
||||||
with self.swallow_mpv_errors([
|
mpv.ErrorCode.PROPERTY_UNAVAILABLE, mpv.ErrorCode.PROPERTY_ERROR]):
|
||||||
mpv.ErrorCode.PROPERTY_UNAVAILABLE,
|
|
||||||
mpv.ErrorCode.PROPERTY_ERROR]):
|
|
||||||
rv = getattr(self.m, name)
|
rv = getattr(self.m, name)
|
||||||
if rv is not None and callable(ptype):
|
if rv is not None and callable(ptype):
|
||||||
# Technically, any property can return None (even if of type e.g. int)
|
# Technically, any property can return None (even if of type e.g. int)
|
||||||
|
|
@ -79,8 +77,7 @@ class TestProperties(unittest.TestCase):
|
||||||
for name, (ptype, access, *_args) in sorted(mpv.ALL_PROPERTIES.items()):
|
for name, (ptype, access, *_args) in sorted(mpv.ALL_PROPERTIES.items()):
|
||||||
if 'w' in access:
|
if 'w' in access:
|
||||||
name = name.replace('-', '_')
|
name = name.replace('-', '_')
|
||||||
with self.subTest(property_name=name):
|
with self.subTest(property_name=name), self.swallow_mpv_errors([
|
||||||
with self.swallow_mpv_errors([
|
|
||||||
mpv.ErrorCode.PROPERTY_UNAVAILABLE,
|
mpv.ErrorCode.PROPERTY_UNAVAILABLE,
|
||||||
mpv.ErrorCode.PROPERTY_ERROR,
|
mpv.ErrorCode.PROPERTY_ERROR,
|
||||||
mpv.ErrorCode.PROPERTY_FORMAT]): # This is due to a bug with option-mapped properties in mpv 0.18.1
|
mpv.ErrorCode.PROPERTY_FORMAT]): # This is due to a bug with option-mapped properties in mpv 0.18.1
|
||||||
|
|
@ -112,11 +109,8 @@ class TestProperties(unittest.TestCase):
|
||||||
while self.m.core_idle:
|
while self.m.core_idle:
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
for name in sorted(self.m):
|
for name in sorted(self.m):
|
||||||
with self.subTest(option_name=name):
|
with self.subTest(option_name=name), self.swallow_mpv_errors([
|
||||||
with self.swallow_mpv_errors([
|
mpv.ErrorCode.PROPERTY_UNAVAILABLE, mpv.ErrorCode.PROPERTY_NOT_FOUND, mpv.ErrorCode.PROPERTY_ERROR]):
|
||||||
mpv.ErrorCode.PROPERTY_UNAVAILABLE,
|
|
||||||
mpv.ErrorCode.PROPERTY_NOT_FOUND,
|
|
||||||
mpv.ErrorCode.PROPERTY_ERROR]):
|
|
||||||
self.m[name]
|
self.m[name]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue