mirror of
https://xff.cz/git/u-boot/
synced 2025-11-01 10:56:02 +01:00
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>
This commit is contained in:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user