• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python patcher.OsPatcher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.patcher.OsPatcher的典型用法代码示例。如果您正苦于以下问题:Python OsPatcher类的具体用法?Python OsPatcher怎么用?Python OsPatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: CMakeTest

class CMakeTest(TestCase):
    def setUp(self):
        self._config = {
            'roots': [
                P('r'),
            ]
        }
        self._patcher = OsPatcher({
            'bdemeta.json': '{"roots": ["r"]}',
            'r': {
                'standalones': {
                    'p': {
                        'package': {
                            'p.dep': '',
                            'p.mem': '',
                        },
                    },
                },
            },
        })

    def tearDown(self):
        self._patcher.reset()

    def test_generate_cmake(self):
        output1 = StringIO()

        run(output1, None, output1, None, ['cmake', 'bdemeta.json', 'p'])

        r       = TargetResolver(self._config)
        p       = resolve(r, 'p')
        output2 = StringIO()
        generate(p, output2)

        assert(output1.getvalue() == output2.getvalue())
开发者ID:frutiger,项目名称:bdemeta,代码行数:35,代码来源:test_bdemeta.py


示例2: NoConfigMainTest

class NoConfigMainTest(TestCase):
    def setUp(self):
        self._patcher = OsPatcher({
        })

    def tearDown(self):
        self._patcher.reset()

    def test_help_text(self):
        stdout = StringIO()
        stderr = StringIO()
        main(stdout, stderr, None, None, [__name__])
        assert(not stdout.getvalue())
        assert(stderr.getvalue())

    def test_no_config_error(self):
        stdout = StringIO()
        stderr = StringIO()
        main(stdout,
             stderr,
             None,
             None,
             [__name__, 'walk', 'bdemeta.json', 'p1'])
        assert(not stdout.getvalue())
        assert(stderr.getvalue())
开发者ID:frutiger,项目名称:bdemeta,代码行数:25,代码来源:test_bdemeta.py


示例3: RunTest

class RunTest(TestCase):
    def setUp(self):
        self._config = {
            'roots': [
                P('r'),
            ]
        }
        self._patcher = OsPatcher({
            '.bdemeta.conf': '{"roots": ["r"]}',
            'r': {
                'groups': {
                    'gr1': {
                        'group': {
                            'gr1.dep': '',
                            'gr1.mem': 'gr1p1 gr1p2',
                        },
                        'gr1p1': {
                            'package': {
                                'gr1p1.dep': '',
                                'gr1p1.mem': '',
                            },
                        },
                        'gr1p2': {
                            'package': {
                                'gr1p2.dep': '',
                                'gr1p2.mem': '',
                            },
                        },
                    },
                    'gr2': {
                        'group': {
                            'gr2.dep': 'gr1',
                            'gr2.mem': '',
                        },
                    },
                },
            },
        })

    def tearDown(self):
        self._patcher.reset()

    def test_no_mode_error(self):
        with self.assertRaises(InvalidArgumentsError) as e:
            run(None, None, None, None, None, [])
        assert('No mode specified' == e.exception.args[0])

    def test_unknown_mode_error(self):
        with self.assertRaises(InvalidArgumentsError) as e:
            run(None, None, None, None, None, ['foo'])
        assert('Unknown mode \'{}\''.format('foo') == e.exception.args[0])

    def test_target_with_dependencies(self):
        f = StringIO()
        run(f, None, None, None, None, ['walk', 'gr2'])

        r  = TargetResolver(self._config)
        us = resolve(r, ['gr2'])

        assert(' '.join(u.name for u in us) + '\n' == f.getvalue())
开发者ID:cppguru,项目名称:bdemeta,代码行数:60,代码来源:test_bdemeta.py


示例4: CMakeResolverTest

class CMakeResolverTest(TestCase):
    def setUp(self):
        self.config = {
            'roots': [
                P('r'),
            ]
        }
        self._patcher = OsPatcher({
            'r': {
                'thirdparty': {
                    't1': {
                        'CMakeLists.txt': '',
                    },
                },
            },
        })

    def tearDown(self):
        self._patcher.reset()

    def test_cmake_identification(self):
        r = TargetResolver(self.config)
        assert({
            'type': 'cmake',
            'path': P('r')/'thirdparty'/'t1'
        } == r.identify('t1'))

    def test_cmake_path(self):
        r = TargetResolver(self.config)
        t = r.resolve('t1', {})
        assert(P('r')/'thirdparty'/'t1' == t.path())
开发者ID:tdoug870,项目名称:bde-meta,代码行数:31,代码来源:test_resolver.py


示例5: GraphTest

class GraphTest(TestCase):
    def setUp(self):
        self._patcher = OsPatcher({
            '.bdemeta.conf': '{"roots": ["r"]}',
            'r': {
                'adapters': {
                    'p1': {
                        'package': {
                            'p1.dep': '',
                            'p1.mem': '',
                        },
                    },
                    'p2': {
                        'package': {
                            'p2.dep': 'p1',
                            'p2.mem': '',
                        },
                    },
                },
            },
        })

    def tearDown(self):
        self._patcher.reset()

    def test_graph(self):
        f = StringIO()
        run(f, None, None, None, None, ['dot', 'p2'])
        lines = f.getvalue().split('\n')
        assert('digraph G {'      == lines[0])
        assert('    "p2" -> "p1"' == lines[1])
        assert('}'                == lines[2])
开发者ID:cppguru,项目名称:bdemeta,代码行数:32,代码来源:test_bdemeta.py


示例6: NoRootTest

class NoRootTest(TestCase):
    def setUp(self):
        self._patcher = OsPatcher({
            'bdemeta.json': '{"roots": ["r"]}',
        })

    def tearDown(self):
        self._patcher.reset()

    def test_no_root_error(self):
        with self.assertRaises(InvalidPathError) as e:
            run(None, None, None, None, ['walk', 'bdemeta.json'])
        assert(P('r') == e.exception.args[0])

    def test_no_root_main_error(self):
        stdout = StringIO()
        stderr = StringIO()
        main(stdout,
             stderr,
             None,
             None,
             [__name__, 'walk', 'bdemeta.json', 'p1'])
        assert(not stdout.getvalue())
        assert(stderr.getvalue())
        assert('r' in stderr.getvalue())
开发者ID:frutiger,项目名称:bdemeta,代码行数:25,代码来源:test_bdemeta.py


示例7: BdeItemsTest

class BdeItemsTest(TestCase):
    def setUp(self):
        self._patcher = OsPatcher({
            'one': {
                'char': 'a',
                'commented': {
                    'item': '# a',
                },
                'real': {
                    'one': {
                        'comment': 'a\n#b',
                    },
                },
            },
            'longer': {
                'char': 'ab',
            },
            'two': {
                'same': {
                    'line': 'a b',
                },
                'diff': {
                    'lines': 'a\nb',
                },
                'commented': {
                    'same': {
                        'line': '# a b',
                    },
                },
            },
        })

    def tearDown(self):
        self._patcher.reset()

    def test_one_char_item(self):
        assert({'a'} == bde_items(P('one')/'char'))

    def test_longer_char_item(self):
        assert({'ab'} == bde_items(P('longer')/'char'))

    def test_two_items_on_same_line(self):
        assert({'a', 'b'} == bde_items(P('two')/'same'/'line'))

    def test_item_on_each_line(self):
        assert({'a', 'b'} == bde_items(P('two')/'diff'/'lines'))

    def test_one_commented_item(self):
        assert(set() == bde_items(P('one')/'commented'/'item'))

    def test_two_commented_items_same_line(self):
        assert(set() == bde_items(P('two')/'commented'/'same'/'line'))

    def test_one_real_one_comment(self):
        assert({'a'} == bde_items(P('one')/'real'/'one'/'comment'))
开发者ID:tdoug870,项目名称:bde-meta,代码行数:55,代码来源:test_resolver.py


示例8: NoConfigErrorTest

class NoConfigErrorTest(TestCase):
    def setUp(self):
        self._patcher = OsPatcher({})

    def tearDown(self):
        self._patcher.reset()

    def test_no_config_error(self):
        caught = False
        try:
            run(StringIO(), ['walk', 'foo'])
        except NoConfigError as e:
            caught = True
        assert(caught)
开发者ID:tdoug870,项目名称:bde-meta,代码行数:14,代码来源:test_bdemeta.py


示例9: setUp

 def setUp(self):
     self._patcher = OsPatcher({
         'bdemeta.json': '{"roots": ["r"]}',
         'r': {
             'standalones': {
                 'p1': {
                     'package': {
                         'p1.dep': '',
                         'p1.mem': '',
                     },
                 },
                 'p2': {
                     'package': {
                         'p2.dep': 'p1',
                         'p2.mem': '',
                     },
                 },
                 'p3': {
                     'package': {
                         'p3.dep': 'p4',
                         'p3.mem': '',
                     },
                 },
                 'p4': {
                     'package': {
                         'p4.dep': 'p3',
                         'p4.mem': '',
                     },
                 },
             },
         },
     })
开发者ID:frutiger,项目名称:bdemeta,代码行数:32,代码来源:test_bdemeta.py


示例10: InvalidPathErrorTest

class InvalidPathErrorTest(TestCase):
    def setUp(self):
        self._patcher = OsPatcher({
            '.bdemeta.conf': '{ "roots": ["unlikely_path_that_exists"] }',
        })

    def tearDown(self):
        self._patcher.reset()

    def test_invalid_path_error(self):
        with self.assertRaises(InvalidPathError):
            run(None, None, None, None, None, ['walk', 'foo'])

        stderr = StringIO()
        main(None, stderr, None, None, None, [__name__, 'walk', 'foo'])
        assert(stderr.getvalue())
开发者ID:cppguru,项目名称:bdemeta,代码行数:16,代码来源:test_bdemeta.py


示例11: setUp

 def setUp(self):
     self.config = {
         'roots': [
             P('r'),
         ]
     }
     self._patcher = OsPatcher({
         'r': {
             'adapters': {
                 'p1': {
                     'package': {
                         'p1.dep': '',
                         'p1.mem': 'p1c1 p1c2',
                     },
                 },
                 'p2': {
                     'package': {
                         'p2.dep': 'p1',
                         'p2.mem': '',
                     },
                 },
                 'p3': {
                     'package': {
                         'p3.dep': '',
                         'p3.mem': '',
                     },
                     'p3.cmake': '',
                 },
             },
         },
     })
开发者ID:cppguru,项目名称:bdemeta,代码行数:31,代码来源:test_resolver.py


示例12: setUp

 def setUp(self):
     self._patcher = OsPatcher({
         'one': {
             'char': 'a',
             'commented': {
                 'item': '# a',
             },
             'real': {
                 'one': {
                     'comment': 'a\n#b',
                 },
             },
         },
         'longer': {
             'char': 'ab',
         },
         'two': {
             'same': {
                 'line': 'a b',
             },
             'diff': {
                 'lines': 'a\nb',
             },
             'commented': {
                 'same': {
                     'line': '# a b',
                 },
             },
         },
     })
开发者ID:tdoug870,项目名称:bde-meta,代码行数:30,代码来源:test_resolver.py


示例13: NotFoundErrorsTest

class NotFoundErrorsTest(TestCase):
    def setUp(self):
        self.config = {
            'roots': [
                P('r'),
            ]
        }
        self._patcher = OsPatcher({
            'r': { },
        })

    def tearDown(self):
        self._patcher.reset()

    def test_non_identification(self):
        r = TargetResolver(self.config)
        with self.assertRaises(TargetNotFoundError):
            r.identify('foo')
开发者ID:cppguru,项目名称:bdemeta,代码行数:18,代码来源:test_resolver.py


示例14: CMakeTest

class CMakeTest(TestCase):
    def setUp(self):
        self._config = {
            'roots': [
                P('r'),
            ]
        }
        self._patcher = OsPatcher({
            '.bdemeta.conf': '{"roots": ["r"]}',
            'r': {
                'adapters': {
                    'p': {
                        'package': {
                            'p.dep': '',
                            'p.mem': '',
                        },
                    },
                },
            },
        })

    def tearDown(self):
        self._patcher.reset()

    def test_generate_cmake(self):
        output = StringIO()

        f1 = {}
        w1 = get_filestore_writer(f1)

        run(output, None, w1, None, None, ['cmake', 'p'])

        r  = TargetResolver(self._config)
        p  = resolve(r, 'p')
        f2 = {}
        w2 = get_filestore_writer(f2)
        generate(p, w2)

        assert(f1.keys() == f2.keys())
        for k in f1:
            assert(f1[k].getvalue() == f2[k].getvalue())
开发者ID:cppguru,项目名称:bdemeta,代码行数:41,代码来源:test_bdemeta.py


示例15: LazilyBoundTest

class LazilyBoundTest(TestCase):
    def setUp(self):
        self.config = {
            'roots': [
                P('r'),
            ],
            'providers': {
                'p1': ['bar']
            },
            'runtime_libraries': [
                'bar'
            ]
        }
        self._patcher = OsPatcher({
            'r': {
                'adapters': {
                    'p1': {
                        'package': {
                            'p1.dep': '',
                            'p1.mem': '',
                        },
                    },
                    'p2': {
                        'package': {
                            'p2.dep': 'bar',
                            'p2.mem': '',
                        },
                    }
                },
            }
        })

    def tearDown(self):
        self._patcher.reset()

    def test_lazily_bound_bar(self):
        r   = TargetResolver(self.config)
        p1  = r.resolve('p1',  {})
        bar = r.resolve('bar', { 'p1': p1 })
        p2  = r.resolve('p2',  { 'bar': bar, 'p1': p1 })
        assert(p2.lazily_bound)
开发者ID:cppguru,项目名称:bdemeta,代码行数:41,代码来源:test_resolver.py


示例16: NoConfigErrorTest

class NoConfigErrorTest(TestCase):
    def setUp(self):
        self._patcher = OsPatcher({})

    def tearDown(self):
        self._patcher.reset()

    def test_no_config_error(self):
        with self.assertRaises(NoConfigError):
            run(None, None, None, None, None, ['walk', 'foo'])

        stderr = StringIO()
        main(None, stderr, None, None, None, [__name__, 'walk', 'foo'])
        assert(stderr.getvalue())

    def test_args_error_if_config_unneeded(self):
        with self.assertRaises(InvalidArgumentsError):
            run(None, None, None, None, None, [])

        stderr = StringIO()
        main(None, stderr, None, None, None, [__name__])
        assert(stderr.getvalue())
开发者ID:cppguru,项目名称:bdemeta,代码行数:22,代码来源:test_bdemeta.py


示例17: NotFoundErrorsTest

class NotFoundErrorsTest(TestCase):
    def setUp(self):
        self.config = {
            'roots': [
                P('r'),
            ]
        }
        self._patcher = OsPatcher({
            'r': { },
        })

    def tearDown(self):
        self._patcher.reset()

    def test_non_identification(self):
        r = TargetResolver(self.config)
        caught = False
        try:
            r.identify('foo')
        except TargetNotFoundError:
            caught = True
        assert(caught)
开发者ID:tdoug870,项目名称:bde-meta,代码行数:22,代码来源:test_resolver.py


示例18: PkgConfigResolverTest

class PkgConfigResolverTest(TestCase):
    def setUp(self):
        self.config = {
            'roots': [
                P('r'),
            ],
            'pkg_configs': {
                'foo': 'bar',
            },
        }
        self._patcher = OsPatcher({
        })

    def tearDown(self):
        self._patcher.reset()

    def test_pkg_identification(self):
        r = TargetResolver(self.config)
        assert(Identification('pkg_config', None, 'bar') == r.identify('foo'))

    def test_pkg_name(self):
        r = TargetResolver(self.config)
        t = r.resolve('foo', {})
        assert('bar' == t.package)
开发者ID:cppguru,项目名称:bdemeta,代码行数:24,代码来源:test_resolver.py


示例19: StandaloneResolverTest

class StandaloneResolverTest(TestCase):
    def setUp(self):
        self.config = {
            'roots': [
                P('r'),
            ]
        }
        self._patcher = OsPatcher({
            'r': {
                'adapters': {
                    'p1': {
                        'package': {
                            'p1.dep': '',
                            'p1.mem': 'p1c1 p1c2',
                        },
                    },
                    'p2': {
                        'package': {
                            'p2.dep': 'p1',
                            'p2.mem': '',
                        },
                    },
                },
            },
        })

    def tearDown(self):
        self._patcher.reset()

    def test_adapter_identification(self):
        r = TargetResolver(self.config)
        assert({
            'type': 'package',
            'path': P('r')/'adapters'/'p1'
        } == r.identify('p1'))

    def test_standalone_with_one_dependency(self):
        r = TargetResolver(self.config)
        assert(set(['p1']) == r.dependencies('p2'))

    def test_level_one_standalone_resolution(self):
        r = TargetResolver(self.config)

        p1 = r.resolve('p1', {})
        assert('p1' == p1)

    def test_level_one_standalone_resolution_components(self):
        r = TargetResolver(self.config)

        p1 = r.resolve('p1', {})
        assert('p1' == p1)

        c1 = P('r')/'adapters'/'p1'/'p1c1.cpp'
        c2 = P('r')/'adapters'/'p1'/'p1c2.cpp'
        assert([c1, c2] == list(sorted(p1.sources())))

    def test_level_two_group_resolution(self):
        r = TargetResolver(self.config)

        p1 = r.resolve('p1', {})
        assert('p1' == p1)

        p2 = r.resolve('p2', { 'p1': p1 })
        assert('p2' == p2)
开发者ID:tdoug870,项目名称:bde-meta,代码行数:64,代码来源:test_resolver.py


示例20: TargetResolverTest

class TargetResolverTest(TestCase):
    def setUp(self):
        self.config = {
            'roots': [
                P('r'),
            ]
        }
        self._patcher = OsPatcher({
            'r': {
                'groups': {
                    'gr1': {
                        'group': {
                            'gr1.dep': '',
                            'gr1.mem': 'gr1p1 gr1p2',
                        },
                        'gr1p1': {
                            'package': {
                                'gr1p1.dep': '',
                                'gr1p1.mem': '',
                            },
                        },
                        'gr1p2': {
                            'package': {
                                'gr1p2.dep': '',
                                'gr1p2.mem': '',
                            },
                        },
                    },
                    'gr2': {
                        'group': {
                            'gr2.dep': 'gr1',
                            'gr2.mem': '',
                        },
                    },
                },
            },
        })

    def tearDown(self):
        self._patcher.reset()

    def test_group_identification(self):
        r = TargetResolver(self.config)
        assert({
            'type': 'group',
            'path': P('r')/'groups'/'gr1'
        } == r.identify('gr1'))

    def test_group_with_one_dependency(self):
        r = TargetResolver(self.config)
        assert(set(['gr1']) == r.dependencies('gr2'))

    def test_level_one_group_resolution(self):
        r = TargetResolver(self.config)

        gr1 = r.resolve('gr1', {})
        assert('gr1' == gr1)

    def test_level_one_group_resolution_packages(self):
        ur = TargetResolver(self.config)
        pr = PackageResolver(P('r')/'groups'/'gr1')

        gr1 = ur.resolve('gr1', {})
        assert('gr1' == gr1)
        assert(resolve(pr, ['gr1p1', 'gr1p2']) == gr1._packages)

    def test_level_two_group_resolution(self):
        r = TargetResolver(self.config)

        gr1 = r.resolve('gr1', {})
        gr2 = r.resolve('gr2', { 'gr1': gr1 })
        assert('gr2' == gr2)
开发者ID:tdoug870,项目名称:bde-meta,代码行数:72,代码来源:test_resolver.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python presto_installer.StandalonePrestoInstaller类代码示例发布时间:2022-05-27
下一篇:
Python helper.APITestHelper类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap