aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/tests/fetch.py
diff options
context:
space:
mode:
authorPeter Hoyes <Peter.Hoyes@arm.com>2023-06-16 13:36:50 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-06-27 15:27:02 +0100
commit2d28caa01bab9540d2bbaf713ae3e5c563d003f5 (patch)
tree7aa1675d7046b8c95fd5681e3da23af851bc3a0c /lib/bb/tests/fetch.py
parent0c7079d0609a13713b890a9675abd9fba032f199 (diff)
downloadbitbake-contrib-2d28caa01bab9540d2bbaf713ae3e5c563d003f5.tar.gz
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. Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/tests/fetch.py')
-rw-r--r--lib/bb/tests/fetch.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 8ca7e6c15..20593764f 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -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)