aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-10-29 21:46:14 -0600
committerSimon Glass <sjg@chromium.org>2020-11-05 09:11:31 -0700
commit366954fdd75200852c134003de4a66b0a20f9362 (patch)
tree76a4d5f94c34a550c273ea4b455ad0d60a90089c /tools
parent427b028aeb2f3678aced5568a5d86c2fff406f46 (diff)
downloadu-boot-366954fdd75200852c134003de4a66b0a20f9362.zip
u-boot-366954fdd75200852c134003de4a66b0a20f9362.tar.gz
u-boot-366954fdd75200852c134003de4a66b0a20f9362.tar.bz2
patman: Use capture_sys_output() consistently
One test still uses its own function for capturing output. Modify it to use the standard one in test_util Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/patman/func_test.py20
1 files changed, 2 insertions, 18 deletions
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 7fffe64..263cb34 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -4,7 +4,6 @@
# Copyright 2017 Google, Inc
#
-import contextlib
import os
import re
import shutil
@@ -12,8 +11,6 @@ import sys
import tempfile
import unittest
-from io import StringIO
-
from patman import control
from patman import gitutil
from patman import patchstream
@@ -29,19 +26,6 @@ except ModuleNotFoundError:
HAVE_PYGIT2 = False
-@contextlib.contextmanager
-def capture():
- oldout, olderr = sys.stdout, sys.stderr
- try:
- out = [StringIO(), StringIO()]
- sys.stdout, sys.stderr = out
- yield out
- finally:
- sys.stdout, sys.stderr = oldout, olderr
- out[0] = out[0].getvalue()
- out[1] = out[1].getvalue()
-
-
class TestFunctional(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp(prefix='patman.')
@@ -169,7 +153,7 @@ class TestFunctional(unittest.TestCase):
text = self.GetText('test01.txt')
series = patchstream.GetMetaDataForTest(text)
cover_fname, args = self.CreatePatchesForTest(series)
- with capture() as out:
+ with capture_sys_output() as out:
patchstream.FixPatches(series, args)
if cover_fname and series.get('cover'):
patchstream.InsertCoverLetter(cover_fname, series, count)
@@ -184,7 +168,7 @@ class TestFunctional(unittest.TestCase):
cc_lines = open(cc_file, encoding='utf-8').read().splitlines()
os.remove(cc_file)
- lines = out[0].splitlines()
+ lines = out[0].getvalue().splitlines()
self.assertEqual('Cleaned %s patches' % len(series.commits), lines[0])
self.assertEqual('Change log missing for v2', lines[1])
self.assertEqual('Change log missing for v3', lines[2])