当前位置: 首页>>代码示例>>Python>>正文


Python Defaults.get方法代码示例

本文整理汇总了Python中kiwi.defaults.Defaults.get方法的典型用法代码示例。如果您正苦于以下问题:Python Defaults.get方法的具体用法?Python Defaults.get怎么用?Python Defaults.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kiwi.defaults.Defaults的用法示例。


在下文中一共展示了Defaults.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestDefaults

# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import get [as 别名]
class TestDefaults(object):
    def setup(self):
        self.defaults = Defaults()

    def test_get(self):
        assert self.defaults.get('kiwi_align') == 1048576
        assert self.defaults.get('kiwi_startsector') == 2048
        assert self.defaults.get('kiwi_sectorsize') == 512
        assert self.defaults.get('kiwi_inode_size') == 256
        assert self.defaults.get('kiwi_inode_ratio') == 16384
        assert self.defaults.get('kiwi_min_inodes') == 20000
        assert self.defaults.get('kiwi_revision')

    def test_to_profile(self):
        profile = mock.MagicMock()
        self.defaults.to_profile(profile)
        profile.add.assert_any_call('kiwi_align', 1048576)
        profile.add.assert_any_call('kiwi_startsector', 2048)
        profile.add.assert_any_call('kiwi_sectorsize', 512)
        profile.add.assert_any_call(
            'kiwi_revision', self.defaults.get('kiwi_revision')
        )

    def test_get_preparer(self):
        assert Defaults.get_preparer() == 'KIWI - http://suse.github.com/kiwi'

    def test_get_publisher(self):
        assert Defaults.get_publisher() == 'SUSE LINUX GmbH'
开发者ID:k0da,项目名称:kiwi-1,代码行数:30,代码来源:defaults_test.py

示例2: TestDefaults

# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import get [as 别名]
class TestDefaults(object):
    def setup(self):
        self.defaults = Defaults()

    def teardown(self):
        sys.argv = argv_kiwi_tests

    def test_get(self):
        assert self.defaults.get('kiwi_align') == 1048576
        assert self.defaults.get('kiwi_startsector') == 2048
        assert self.defaults.get('kiwi_sectorsize') == 512
        assert self.defaults.get('kiwi_inode_size') == 256
        assert self.defaults.get('kiwi_inode_ratio') == 16384
        assert self.defaults.get('kiwi_min_inodes') == 20000
        assert self.defaults.get('kiwi_revision')

    def test_to_profile(self):
        profile = mock.MagicMock()
        self.defaults.to_profile(profile)
        profile.add.assert_any_call('kiwi_align', 1048576)
        profile.add.assert_any_call('kiwi_startsector', 2048)
        profile.add.assert_any_call('kiwi_sectorsize', 512)
        profile.add.assert_any_call(
            'kiwi_revision', self.defaults.get('kiwi_revision')
        )

    def test_get_preparer(self):
        assert Defaults.get_preparer() == 'KIWI - http://suse.github.com/kiwi'

    def test_get_publisher(self):
        assert Defaults.get_publisher() == 'SUSE LINUX GmbH'

    def test_get_default_shared_cache_location(self):
        assert Defaults.get_shared_cache_location() == 'var/cache/kiwi'

    def test_get_custom_shared_cache_location(self):
        sys.argv = [
            sys.argv[0],
            '--shared-cache-dir', '/my/cachedir',
            'system', 'prepare',
            '--description', 'description', '--root', 'directory'
        ]
        assert Defaults.get_shared_cache_location() == 'my/cachedir'
开发者ID:matt4d617474,项目名称:kiwi,代码行数:45,代码来源:defaults_test.py

示例3: TestDefaults

# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import get [as 别名]
class TestDefaults(object):
    def setup(self):
        self.defaults = Defaults()

    def teardown(self):
        sys.argv = argv_kiwi_tests

    def test_get(self):
        assert self.defaults.get('kiwi_align') == 1048576
        assert self.defaults.get('kiwi_startsector') == 2048
        assert self.defaults.get('kiwi_sectorsize') == 512
        assert self.defaults.get('kiwi_inode_size') == 256
        assert self.defaults.get('kiwi_inode_ratio') == 16384
        assert self.defaults.get('kiwi_min_inodes') == 20000
        assert self.defaults.get('kiwi_revision')

    def test_to_profile(self):
        profile = mock.MagicMock()
        self.defaults.to_profile(profile)
        profile.add.assert_any_call('kiwi_align', 1048576)
        profile.add.assert_any_call('kiwi_startsector', 2048)
        profile.add.assert_any_call('kiwi_sectorsize', 512)
        profile.add.assert_any_call(
            'kiwi_revision', self.defaults.get('kiwi_revision')
        )

    def test_get_preparer(self):
        assert Defaults.get_preparer() == 'KIWI - http://suse.github.com/kiwi'

    def test_get_publisher(self):
        assert Defaults.get_publisher() == 'SUSE LINUX GmbH'

    def test_get_default_shared_cache_location(self):
        assert Defaults.get_shared_cache_location() == 'var/cache/kiwi'

    def test_get_custom_shared_cache_location(self):
        sys.argv = [
            sys.argv[0],
            '--shared-cache-dir', '/my/cachedir',
            'system', 'prepare',
            '--description', 'description', '--root', 'directory'
        ]
        assert Defaults.get_shared_cache_location() == 'my/cachedir'

    @patch('kiwi.defaults.Path.which')
    def test_get_grub_boot_directory_name(self, mock_which):
        mock_which.return_value = 'grub2-install-was-found'
        assert Defaults.get_grub_boot_directory_name(
            lookup_path='lookup_path'
        ) == 'grub2'
        mock_which.return_value = None
        assert Defaults.get_grub_boot_directory_name(
            lookup_path='lookup_path'
        ) == 'grub'

    @patch('kiwi.defaults.sys')
    @patch('kiwi.defaults.reload_module')
    def test_set_python_default_encoding_to_utf8(self, mock_reload, mock_sys):
        mock_sys.version_info.major = 2
        Defaults.set_python_default_encoding_to_utf8()
        mock_reload.assert_called_once_with(mock_sys)
        mock_sys.setdefaultencoding.assert_called_once_with('utf-8')

    def test_get_live_dracut_module_from_flag(self):
        assert Defaults.get_live_dracut_module_from_flag('foo') == \
            'kiwi-live'
        assert Defaults.get_live_dracut_module_from_flag('overlay') == \
            'kiwi-live'
        assert Defaults.get_live_dracut_module_from_flag('dmsquash') == \
            'dmsquash-live'

    @patch('platform.machine')
    def test_get_iso_boot_path(self, mock_machine):
        mock_machine.return_value = 'i686'
        assert Defaults.get_iso_boot_path() == 'boot/ix86'
        mock_machine.return_value = 'x86_64'
        assert Defaults.get_iso_boot_path() == 'boot/x86_64'

    @patch('kiwi.defaults.glob.iglob')
    def test_get_unsigned_grub_loader(self, mock_glob):
        mock_glob.return_value = ['/usr/lib/grub2/x86_64-efi/grub.efi']
        assert Defaults.get_unsigned_grub_loader('root') == \
            mock_glob.return_value.pop()
        mock_glob.assert_called_once_with('root/usr/lib/grub*/*-efi/grub.efi')
开发者ID:adrianschroeter,项目名称:kiwi,代码行数:86,代码来源:defaults_test.py


注:本文中的kiwi.defaults.Defaults.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。