mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 00:20:08 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
8b0fc4850d
commit
fd1d2c6dc7
@@ -3183,7 +3183,7 @@ class FetchPremirroronlyBrokenTarball(FetcherTest):
|
||||
import sys
|
||||
self.d.setVar("SRCREV", "0"*40)
|
||||
fetcher = bb.fetch.Fetch([self.recipe_url], self.d)
|
||||
with self.assertRaises(bb.fetch2.FetchError):
|
||||
with self.assertRaises(bb.fetch2.FetchError), self.assertLogs() as logs:
|
||||
fetcher.download()
|
||||
stdout = sys.stdout.getvalue()
|
||||
self.assertFalse(" not a git repository (or any parent up to mount point /)" in stdout)
|
||||
output = "".join(logs.output)
|
||||
self.assertFalse(" not a git repository (or any parent up to mount point /)" in output)
|
||||
|
||||
Reference in New Issue
Block a user