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


Python TempDirectory.compare方法代码示例

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



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

示例1: test_evaulate_write

# 需要导入模块: from testfixtures import TempDirectory [as 别名]
# 或者: from testfixtures.TempDirectory import compare [as 别名]
 def test_evaulate_write(self):
     dir = TempDirectory()
     d = TestContainer('parsed',FileBlock('foo','content','write'))
     d.evaluate_with(Files('td'),globs={'td':dir})
     compare([C(FileResult,
                passed=True,
                expected=None,
                actual=None)],
             [r.evaluated for r in d])
     dir.compare(['foo'])
     compare(dir.read('foo', 'ascii'), 'content')
开发者ID:nedbat,项目名称:testfixtures,代码行数:13,代码来源:test_manuel.py


示例2: TestPrepareTarget

# 需要导入模块: from testfixtures import TempDirectory [as 别名]
# 或者: from testfixtures.TempDirectory import compare [as 别名]
class TestPrepareTarget(TestCase):

    def setUp(self):
        self.dir = TempDirectory()
        self.addCleanup(self.dir.cleanup)
        replace = Replacer()
        replace('workfront.generate.TARGET_ROOT', self.dir.path)
        self.addCleanup(replace.restore)
        self.session = Session('test')

    def test_from_scratch(self):
        path = prepare_target(self.session)

        compare(path, expected=self.dir.getpath('unsupported.py'))
        self.dir.compare(expected=[])

    def test_everything(self):
        self.dir.write('unsupported.py', b'yy')
        path = prepare_target(self.session)

        compare(path, expected=self.dir.getpath('unsupported.py'))
        self.dir.compare(expected=['unsupported.py'])
        compare(self.dir.read('unsupported.py'), b"yy")

    def test_dots_in_version(self):
        path = prepare_target(Session('test', api_version='v4.0'))

        compare(path, expected=self.dir.getpath('v40.py'))
        self.dir.compare(expected=[])
开发者ID:cjw296,项目名称:python-workfront,代码行数:31,代码来源:test_generate.py


示例3: TestDecoratedObjectTypes

# 需要导入模块: from testfixtures import TempDirectory [as 别名]
# 或者: from testfixtures.TempDirectory import compare [as 别名]
class TestDecoratedObjectTypes(MockOpenHelper, TestCase):

    def setUp(self):
        super(TestDecoratedObjectTypes, self).setUp()
        self.dir = TempDirectory()
        self.addCleanup(self.dir.cleanup)

    def test_normal(self):
        base_url = 'https://test.attask-ondemand.com/attask/api/v4.0'
        session = Session('test', api_version='v4.0')
        self.server.add(
            url=base_url+'/metadata',
            params='method=GET',
            response=json.dumps(dict(data=dict(objects=dict(
                SomeThing=dict(objCode='SMTHING', name='SomeThing')
            ))))
        )
        expected = dict(
            objCode='SMTHING',
            name='SomeThing',
            stuff='a value'
        )
        self.server.add(
            url=base_url+'/smthing/metadata',
            params='method=GET',
            response=json.dumps(dict(data=expected))
        )
        compare(decorated_object_types(session, None),
                expected=[('SomeThing', 'SMTHING', expected)])

    def test_cache_write(self):
        base_url = 'https://test.attask-ondemand.com/attask/api/v4.0'
        session = Session('test', api_version='v4.0')
        self.server.add(
            url=base_url+'/metadata',
            params='method=GET',
            response=json.dumps(dict(data=dict(objects=dict(
                SomeThing=dict(objCode='SMTHING', name='SomeThing')
            ))))
        )
        expected = dict(
            objCode='SMTHING',
            name='SomeThing',
            stuff='a value'
        )
        self.server.add(
            url=base_url+'/smthing/metadata',
            params='method=GET',
            response=json.dumps(dict(data=expected))
        )
        compare(decorated_object_types(session, self.dir.path),
                expected=[('SomeThing', 'SMTHING', expected)])
        self.dir.compare(expected=[
            'v4.0_metadata.json', 'v4.0_smthing_metadata.json'
        ])
        compare(
            json.loads(self.dir.read('v4.0_metadata.json').decode('ascii')),
            expected=dict(objects=dict(
                SomeThing=dict(objCode='SMTHING', name='SomeThing')
            )))
        compare(
            json.loads(
                self.dir.read('v4.0_smthing_metadata.json').decode('ascii')
            ),
            expected=expected
        )

    def test_cache_read(self):
        expected = dict(
            objCode='SMTHING',
            name='SomeThing',
            stuff='a value'
        )

        self.dir.write('v4.0_metadata.json', json.dumps(dict(objects=dict(
                SomeThing=dict(objCode='SMTHING', name='SomeThing')
        ))), encoding='ascii')

        self.dir.write('v4.0_smthing_metadata.json',
                       json.dumps(expected),
                       encoding='ascii')

        session = Session('test', api_version='v4.0')
        compare(decorated_object_types(session, self.dir.path),
                expected=[('SomeThing', 'SMTHING', expected)])

    def test_unsupported(self):
        base_url = 'https://test.attask-ondemand.com/attask/api/unsupported'
        session = Session('test')
        self.server.add(
            url=base_url+'/metadata',
            params='method=GET',
            response=json.dumps(dict(data=dict(objects=dict(
                SomeThing=dict(objCode='SMTHING', name='SomeThing')
            ))))
        )
        expected = dict(
            objCode='SMTHING',
            name='SomeThing',
            stuff='a value'
#.........这里部分代码省略.........
开发者ID:cjw296,项目名称:python-workfront,代码行数:103,代码来源:test_generate.py


示例4: FunctionalTest

# 需要导入模块: from testfixtures import TempDirectory [as 别名]
# 或者: from testfixtures.TempDirectory import compare [as 别名]
class FunctionalTest(MockOpenHelper, TestCase):

    base = 'https://api-cl01.attask-ondemand.com/attask/api/unsupported'

    def setUp(self):
        super(FunctionalTest, self).setUp()
        self.log = LogCapture()
        self.addCleanup(self.log.uninstall)
        self.dir = TempDirectory()
        self.addCleanup(self.dir.cleanup)
        self.replace('logging.basicConfig', Mock())
        self.replace('workfront.generate.TARGET_ROOT', self.dir.path)

    def test_functional(self):
        self.replace('sys.argv', ['x'])

        self.server.add(
            url='/metadata',
            params='method=GET',
            response=json.dumps(dict(data=dict(objects=dict(
                SomeThing=dict(objCode='BAR', name='SomeThing'),
                OtherThing=dict(objCode='FOO', name='OtherThing'),
            ))))
        )

        self.server.add(
            url='/foo/metadata',
            params='method=GET',
            response=json.dumps(dict(data=dict(
                objCode='FOO',
                name='OtherThing',
                fields={"ID": {}, "anotherField": {}},
                references={},
                collections={},
                actions={},
            )))
        )

        self.server.add(
            url='/bar/metadata',
            params='method=GET',
            response=json.dumps(dict(data=dict(
                objCode='BAR',
                name='SomeThing',
                fields={"ID": {}, "theField": {}},
                references={"accessRules": {}},
                collections={"assignedTo": {}},
                actions={"doSomething": {
                    "arguments": [
                        {
                            "name": "anOption",
                            "type": "Task"
                        },
                        {
                            "name": "options",
                            "type": "string[]"
                        }
                    ],
                    "resultType": "string",
                    "label": "doSomething"
                }}
            )))
        )

        with OutputCapture() as output:
            output.disable()
            main()

        output.compare("")

        self.dir.compare(expected=['unsupported.py'])

        compare(self.dir.read('unsupported.py').decode('ascii'), expected=u'''\
# generated from https://api-cl01.attask-ondemand.com/attask/api/unsupported/metadata
from ..meta import APIVersion, Object, Field, Reference, Collection

api = APIVersion('unsupported')


class OtherThing(Object):
    code = 'FOO'
    another_field = Field('anotherField')

api.register(OtherThing)


class SomeThing(Object):
    code = 'BAR'
    the_field = Field('theField')
    access_rules = Reference('accessRules')
    assigned_to = Collection('assignedTo')

    def do_something(self, an_option=None, options=None):
        """
        The ``doSomething`` action.

        :param an_option: anOption (type: ``Task``)
        :param options: options (type: ``string[]``)
        :return: ``string``
        """
#.........这里部分代码省略.........
开发者ID:cjw296,项目名称:python-workfront,代码行数:103,代码来源:test_generate.py



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