Use fakelogger in test_blockdevice_mbr

Capture logging instead of putting it on stdout

Change-Id: Ic0c9f25549a1984fecf8e912e5b14845e2363730
This commit is contained in:
Ian Wienand 2017-05-17 18:49:12 +10:00
parent e4e23897a1
commit 08e8471360

View File

@ -11,9 +11,7 @@
# under the License.
import copy
from diskimage_builder.block_device.level0.localloop import LocalLoop
from diskimage_builder.block_device.level1.mbr import MBR
from diskimage_builder.logging_config import setup
import fixtures
import logging
import os
import shutil
@ -21,6 +19,12 @@ import subprocess
import tempfile
import testtools
from diskimage_builder.block_device.level0.localloop import LocalLoop
from diskimage_builder.block_device.level1.mbr import MBR
logger = logging.getLogger(__name__)
class TestMBR(testtools.TestCase):
@ -48,7 +52,10 @@ class TestMBR(testtools.TestCase):
def setUp(self):
super(TestMBR, self).setUp()
setup()
fs = '%(asctime)s %(levelname)s [%(name)s] %(message)s'
self.log_fixture = self.useFixture(
fixtures.FakeLogger(level=logging.DEBUG,
format=fs))
def _create_image(self):
tmp_dir = tempfile.mkdtemp(prefix="dib-bd-mbr-")
@ -61,7 +68,7 @@ class TestMBR(testtools.TestCase):
partx_path = self._get_path_for_partx()
largs.insert(0, partx_path)
largs.append(image_path)
logging.info("Running command [%s]", largs)
logger.info("Running command [%s]", largs)
return subprocess.check_output(largs).decode("ascii")
def test_one_ext_partition(self):