Merge "Use fakelogger in test_blockdevice_mbr"

This commit is contained in:
Jenkins 2017-05-17 23:59:18 +00:00 committed by Gerrit Code Review
commit c54e9fddfa

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):