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. # under the License.
import copy import copy
from diskimage_builder.block_device.level0.localloop import LocalLoop import fixtures
from diskimage_builder.block_device.level1.mbr import MBR
from diskimage_builder.logging_config import setup
import logging import logging
import os import os
import shutil import shutil
@ -21,6 +19,12 @@ import subprocess
import tempfile import tempfile
import testtools 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): class TestMBR(testtools.TestCase):
@ -48,7 +52,10 @@ class TestMBR(testtools.TestCase):
def setUp(self): def setUp(self):
super(TestMBR, self).setUp() 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): def _create_image(self):
tmp_dir = tempfile.mkdtemp(prefix="dib-bd-mbr-") tmp_dir = tempfile.mkdtemp(prefix="dib-bd-mbr-")
@ -61,7 +68,7 @@ class TestMBR(testtools.TestCase):
partx_path = self._get_path_for_partx() partx_path = self._get_path_for_partx()
largs.insert(0, partx_path) largs.insert(0, partx_path)
largs.append(image_path) largs.append(image_path)
logging.info("Running command [%s]", largs) logger.info("Running command [%s]", largs)
return subprocess.check_output(largs).decode("ascii") return subprocess.check_output(largs).decode("ascii")
def test_one_ext_partition(self): def test_one_ext_partition(self):