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


Python test_helpers.fixture_path函数代码示例

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


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

示例1: test_can_change_data_path_after_creation

 def test_can_change_data_path_after_creation(self):
     original_path = test_helpers.fixture_path('unicode.txt')
     new_path = test_helpers.fixture_path('foo.txt')
     resource_dict = {
         'path': original_path
     }
     resource = datapackage.Resource.load(resource_dict)
     resource.descriptor['path'] = new_path
     assert resource.data == b'foo\n'
开发者ID:scls19fr,项目名称:datapackage-py,代码行数:9,代码来源:test_resource.py

示例2: test_generates_unique_filenames_for_unnamed_resources

 def test_generates_unique_filenames_for_unnamed_resources(self, tmpfile):
     metadata = {
         'name': 'proverbs',
         'resources': [
             {'path': test_helpers.fixture_path('unicode.txt')},
             {'path': test_helpers.fixture_path('foo.txt')}
         ]
     }
     schema = {}
     dp = datapackage.DataPackage(metadata, schema)
     dp.save(tmpfile)
     with zipfile.ZipFile(tmpfile, 'r') as z:
         files = z.namelist()
         assert sorted(set(files)) == sorted(files)
开发者ID:elisonghe,项目名称:datapackage-py,代码行数:14,代码来源:test_datapackage.py

示例3: test_remote_data_path_returns_none_if_theres_no_remote_data

 def test_remote_data_path_returns_none_if_theres_no_remote_data(self):
     resource_dict = {
         'data': 'foo',
         'path': test_helpers.fixture_path('unicode.txt'),
     }
     resource = datapackage.Resource.load(resource_dict)
     assert resource.remote_data_path is None
开发者ID:scls19fr,项目名称:datapackage-py,代码行数:7,代码来源:test_resource.py

示例4: test_init_raises_if_path_is_a_bad_json

 def test_init_raises_if_path_is_a_bad_json(self):
     bad_json = test_helpers.fixture_path('bad_json.json')
     with pytest.raises(datapackage.exceptions.DataPackageException) as excinfo:
         datapackage.DataPackage(bad_json)
     message = str(excinfo.value)
     assert 'Unable to parse JSON' in message
     assert 'line 2 column 5 (char 6)' in message
开发者ID:frictionlessdata,项目名称:datapackage-py,代码行数:7,代码来源:test_datapackage.py

示例5: test_load_accepts_absolute_paths

 def test_load_accepts_absolute_paths(self):
     path = test_helpers.fixture_path('foo.txt')
     resource_dict = {
         'path': path,
     }
     resource = datapackage.Resource.load(resource_dict)
     assert resource.data == b'foo\n'
开发者ID:scls19fr,项目名称:datapackage-py,代码行数:7,代码来源:test_resource.py

示例6: test_load_binary_data

    def test_load_binary_data(self):
        resource_dict = {
            'path': test_helpers.fixture_path('image.gif'),
        }
        resource = datapackage.Resource.load(resource_dict)

        with open(resource_dict['path'], 'rb') as f:
            assert resource.data == f.read()
开发者ID:scls19fr,项目名称:datapackage-py,代码行数:8,代码来源:test_resource.py

示例7: test_load_prefers_loading_local_data_over_url

 def test_load_prefers_loading_local_data_over_url(self):
     httpretty.HTTPretty.allow_net_connect = False
     resource_dict = {
         'path': test_helpers.fixture_path('foo.txt'),
         'url': 'http://someplace.com/inexistent-file.txt',
     }
     resource = datapackage.Resource.load(resource_dict)
     assert resource.data == b'foo\n'
开发者ID:scls19fr,项目名称:datapackage-py,代码行数:8,代码来源:test_resource.py

示例8: test_works_with_resources_with_relative_paths

 def test_works_with_resources_with_relative_paths(self, tmpfile):
     path = test_helpers.fixture_path(
         'datapackage_with_foo.txt_resource.json'
     )
     dp = datapackage.DataPackage(path)
     dp.save(tmpfile)
     with zipfile.ZipFile(tmpfile, 'r') as z:
         assert len(z.filelist) == 2
开发者ID:elisonghe,项目名称:datapackage-py,代码行数:8,代码来源:test_datapackage.py

示例9: test_local_data_path

    def test_local_data_path(self, datapackage_zip):
        dp = datapackage.DataPackage(datapackage_zip)

        assert dp.resources[0].local_data_path is not None

        with open(test_helpers.fixture_path('foo.txt')) as data_file:
            with open(dp.resources[0].local_data_path) as local_data_file:
                assert local_data_file.read() == data_file.read()
开发者ID:elisonghe,项目名称:datapackage-py,代码行数:8,代码来源:test_datapackage.py

示例10: test_with_local_resources_with_existent_path_isnt_safe

 def test_with_local_resources_with_existent_path_isnt_safe(self):
     metadata = {
         'resources': [
             {'path': test_helpers.fixture_path('foo.txt')},
         ]
     }
     dp = datapackage.DataPackage(metadata, {})
     assert not dp.safe()
开发者ID:elisonghe,项目名称:datapackage-py,代码行数:8,代码来源:test_datapackage.py

示例11: test_local_data_path_returns_the_absolute_path

 def test_local_data_path_returns_the_absolute_path(self):
     base_path = test_helpers.fixture_path('')
     path = os.path.join(base_path, '..', 'fixtures', 'unicode.txt')
     resource_dict = {
         'path': path,
     }
     resource = datapackage.Resource.load(resource_dict)
     abs_path = os.path.join(base_path, 'unicode.txt')
     assert resource.local_data_path == abs_path
开发者ID:scls19fr,项目名称:datapackage-py,代码行数:9,代码来源:test_resource.py

示例12: test_load_accepts_relative_paths

 def test_load_accepts_relative_paths(self):
     filename = 'foo.txt'
     base_path = os.path.dirname(
         test_helpers.fixture_path(filename)
     )
     resource_dict = {
         'path': filename,
     }
     resource = datapackage.Resource.load(resource_dict, base_path)
     assert resource.data == b'foo\n'
开发者ID:scls19fr,项目名称:datapackage-py,代码行数:10,代码来源:test_resource.py

示例13: datapackage_zip

def datapackage_zip(tmpfile):
    metadata = {
        'name': 'proverbs',
        'resources': [
            {'path': test_helpers.fixture_path('foo.txt')},
        ]
    }
    dp = datapackage.DataPackage(metadata)
    dp.save(tmpfile)
    return tmpfile
开发者ID:elisonghe,项目名称:datapackage-py,代码行数:10,代码来源:test_datapackage.py

示例14: _create_resource_file_with

    def _create_resource_file_with(self, fixture):
        path = test_helpers.fixture_path(fixture)
        with open(path, 'rb') as f:
            body = f.read()
        url = 'http://www.someplace.com/{fixture}'.format(fixture=fixture)
        httpretty.register_uri(httpretty.GET,
                               url,
                               body=body)

        return RemoteResourceFile(url)
开发者ID:elisonghe,项目名称:datapackage-py,代码行数:10,代码来源:test_resource_file.py

示例15: test_local_resource_with_absolute_path_is_loaded

 def test_local_resource_with_absolute_path_is_loaded(self):
     path = test_helpers.fixture_path('foo.txt')
     metadata = {
         'resources': [
             {'path': path},
         ],
     }
     dp = datapackage.DataPackage(metadata)
     assert len(dp.resources) == 1
     assert dp.resources[0].data == b'foo\n'
开发者ID:elisonghe,项目名称:datapackage-py,代码行数:10,代码来源:test_datapackage.py


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