diff options
author | Peter Hoyes <Peter.Hoyes@arm.com> | 2023-06-16 13:36:50 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-06-27 15:28:56 +0100 |
commit | fd1d2c6dc73e084918b4290214652bcff9b99261 (patch) | |
tree | 8ccec2318f0d0488c8a07410744608cca374787b /bitbake/lib/bb/tests/fetch.py | |
parent | 8b0fc4850dc31bb7e7be0001414468b1d3f80846 (diff) | |
download | poky-fd1d2c6dc73e084918b4290214652bcff9b99261.tar.gz |
bitbake: bitbake: tests: Use assertLogs to test logging output
By default, pytest captures all stdout and exposes it using its built-in
fixtures (capsys, caplog etc), so stdout does not support getvalue().
To support running tests using both unittest and pytest, use assertLogs
to capture logging and assert on the log output instead.
(Bitbake rev: 2d28caa01bab9540d2bbaf713ae3e5c563d003f5)
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests/fetch.py')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 8ca7e6c155..20593764fd 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -3183,7 +3183,7 @@ class FetchPremirroronlyBrokenTarball(FetcherTest): | |||
3183 | import sys | 3183 | import sys |
3184 | self.d.setVar("SRCREV", "0"*40) | 3184 | self.d.setVar("SRCREV", "0"*40) |
3185 | fetcher = bb.fetch.Fetch([self.recipe_url], self.d) | 3185 | fetcher = bb.fetch.Fetch([self.recipe_url], self.d) |
3186 | with self.assertRaises(bb.fetch2.FetchError): | 3186 | with self.assertRaises(bb.fetch2.FetchError), self.assertLogs() as logs: |
3187 | fetcher.download() | 3187 | fetcher.download() |
3188 | stdout = sys.stdout.getvalue() | 3188 | output = "".join(logs.output) |
3189 | self.assertFalse(" not a git repository (or any parent up to mount point /)" in stdout) | 3189 | self.assertFalse(" not a git repository (or any parent up to mount point /)" in output) |