aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-12-02 10:39:13 -0800
committerEli Schwartz <eschwartz93@gmail.com>2021-12-06 20:06:14 -0500
commit51845a3a45647126866a898f8206fe581840ca92 (patch)
tree47a392a972a9e8e409ee2fd5452e11e645d2c06c
parent930cbdb86d5db3e5222d385fb785359000288d94 (diff)
downloadmeson-51845a3a45647126866a898f8206fe581840ca92.zip
meson-51845a3a45647126866a898f8206fe581840ca92.tar.gz
meson-51845a3a45647126866a898f8206fe581840ca92.tar.bz2
unittests/internal: use more subTest
-rw-r--r--unittests/internaltests.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/unittests/internaltests.py b/unittests/internaltests.py
index a332d81..ba61297 100644
--- a/unittests/internaltests.py
+++ b/unittests/internaltests.py
@@ -1374,7 +1374,7 @@ class InternalTests(unittest.TestCase):
_(None, mock.Mock(), tuple(), dict(native=True))
- @mock.patch.dict(mesonbuild.mesonlib.project_meson_versions, {})
+ @mock.patch('mesonbuild.mesonlib.project_meson_versions', {'': '1.0'})
def test_typed_kwarg_since_values(self) -> None:
@typed_kwargs(
'testfunc',
@@ -1391,33 +1391,31 @@ class InternalTests(unittest.TestCase):
def _(obj, node, args: T.Tuple, kwargs: T.Dict[str, str]) -> None:
pass
- mesonbuild.mesonlib.project_meson_versions[''] = '1.0'
-
- with mock.patch('sys.stdout', io.StringIO()) as out:
+ with self.subTest('deprecated array string value'), mock.patch('sys.stdout', io.StringIO()) as out:
_(None, mock.Mock(subproject=''), [], {'input': ['foo']})
self.assertRegex(out.getvalue(), r"""WARNING:.Project targeting '1.0'.*deprecated since '0.9': "testfunc" keyword argument "input" value "foo".*""")
- with mock.patch('sys.stdout', io.StringIO()) as out:
+ with self.subTest('new array string value'), mock.patch('sys.stdout', io.StringIO()) as out:
_(None, mock.Mock(subproject=''), [], {'input': ['bar']})
self.assertRegex(out.getvalue(), r"""WARNING:.Project targeting '1.0'.*introduced in '1.1': "testfunc" keyword argument "input" value "bar".*""")
- with mock.patch('sys.stdout', io.StringIO()) as out:
+ with self.subTest('deprecated dict string value'), mock.patch('sys.stdout', io.StringIO()) as out:
_(None, mock.Mock(subproject=''), [], {'output': {'foo': 'a'}})
self.assertRegex(out.getvalue(), r"""WARNING:.Project targeting '1.0'.*deprecated since '0.9': "testfunc" keyword argument "output" value "foo".*""")
- with mock.patch('sys.stdout', io.StringIO()) as out:
- _(None, mock.Mock(subproject=''), [], {'install_dir': False})
- self.assertRegex(out.getvalue(), r"""WARNING:.Project targeting '1.0'.*deprecated since '0.9': "testfunc" keyword argument "install_dir" value "False".*""")
-
- with mock.patch('sys.stdout', io.StringIO()) as out:
+ with self.subTest('new dict string value'), mock.patch('sys.stdout', io.StringIO()) as out:
_(None, mock.Mock(subproject=''), [], {'output': {'bar': 'b'}})
self.assertRegex(out.getvalue(), r"""WARNING:.Project targeting '1.0'.*introduced in '1.1': "testfunc" keyword argument "output" value "bar".*""")
- with mock.patch('sys.stdout', io.StringIO()) as out:
+ with self.subTest('non string union'), mock.patch('sys.stdout', io.StringIO()) as out:
+ _(None, mock.Mock(subproject=''), [], {'install_dir': False})
+ self.assertRegex(out.getvalue(), r"""WARNING:.Project targeting '1.0'.*deprecated since '0.9': "testfunc" keyword argument "install_dir" value "False".*""")
+
+ with self.subTest('deprecated string union'), mock.patch('sys.stdout', io.StringIO()) as out:
_(None, mock.Mock(subproject=''), [], {'mode': 'deprecated'})
self.assertRegex(out.getvalue(), r"""WARNING:.Project targeting '1.0'.*deprecated since '1.0': "testfunc" keyword argument "mode" value "deprecated".*""")
- with mock.patch('sys.stdout', io.StringIO()) as out:
+ with self.subTest('new string union'), mock.patch('sys.stdout', io.StringIO()) as out:
_(None, mock.Mock(subproject=''), [], {'mode': 'since'})
self.assertRegex(out.getvalue(), r"""WARNING:.Project targeting '1.0'.*introduced in '1.1': "testfunc" keyword argument "mode" value "since".*""")