本文整理汇总了Python中tests.read_file函数的典型用法代码示例。如果您正苦于以下问题:Python read_file函数的具体用法?Python read_file怎么用?Python read_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_expand_01
def test_expand_01(self):
api = overpy.Overpass()
result1 = api.parse_json(read_file("json/result-expand-01.json"))
assert len(result1.nodes) == 2
assert len(result1.ways) == 1
result2 = api.parse_json(read_file("json/result-expand-02.json"))
assert len(result2.nodes) == 2
assert len(result2.ways) == 1
result1.expand(result2)
# Don't overwrite existing elements
assert len(result1.nodes) == 3
assert len(result1.ways) == 2
开发者ID:DinoTools,项目名称:python-overpy,代码行数:17,代码来源:test_result.py
示例2: test_execute_fixer
def test_execute_fixer(self):
tool = Phpcs(self.problems, {'fixer': True})
original = read_file(self.fixtures[1])
tool.execute_fixer(self.fixtures)
updated = read_and_restore_file(self.fixtures[1], original)
assert original != updated, 'File content should change.'
eq_(0, len(self.problems.all()), 'No errors should be recorded')
开发者ID:esoergel,项目名称:lint-review,代码行数:9,代码来源:test_phpcs.py
示例3: test_attribute_invalid_date
def test_attribute_invalid_date(self):
api = overpy.Overpass()
result = api.parse_json(read_file("json/way-meta_invalid-timestamp.json"))
for o in result.ways + result.nodes:
assert(type(o.attributes['uid']) == int)
assert(type(o.attributes['changeset']) == int)
assert(type(o.attributes['version']) == int)
assert('timestamp' in o.attributes)
开发者ID:Frankkkkk,项目名称:python-overpy,代码行数:9,代码来源:test_result.py
示例4: test_expand_error
def test_expand_error(self):
api = overpy.Overpass()
result = api.parse_json(read_file("json/result-expand-01.json"))
with pytest.raises(ValueError):
result.expand(123)
with pytest.raises(ValueError):
result.expand(1.23)
with pytest.raises(ValueError):
result.expand("abc")
开发者ID:DinoTools,项目名称:python-overpy,代码行数:9,代码来源:test_result.py
示例5: test_execute_fixer__no_problems_remain
def test_execute_fixer__no_problems_remain(self):
tool = Phpcs(self.problems, {'fixer': True})
# The fixture file can have all problems fixed by phpcs
original = read_file(self.fixtures[1])
tool.execute_fixer(self.fixtures)
tool.process_files(self.fixtures)
read_and_restore_file(self.fixtures[1], original)
eq_(0, len(self.problems.all()), 'All errors should be autofixed')
开发者ID:esoergel,项目名称:lint-review,代码行数:10,代码来源:test_phpcs.py
示例6: test_missing_unresolvable
def test_missing_unresolvable(self):
url, server = new_server_thread(HandleResponseJSON02)
api = overpy.Overpass()
api.url = url
result1 = api.parse_json(read_file("json/result-expand-01.json"))
with pytest.raises(overpy.exception.DataIncomplete):
result1.get_node(123, resolve_missing=True)
stop_server_thread(server)
开发者ID:DinoTools,项目名称:python-overpy,代码行数:10,代码来源:test_result.py
示例7: test_execute_fixer
def test_execute_fixer(self):
tool = Ktlint(self.problems, {'fixer': True}, root_dir)
target = root_dir + '/' + self.fixtures[1]
original = read_file(target)
tool.execute_fixer(self.fixtures)
updated = read_and_restore_file(target, original)
assert original != updated, 'File content should change.'
self.assertEqual(0, len(self.problems.all()),
'No errors should be recorded')
开发者ID:markstory,项目名称:lint-review,代码行数:10,代码来源:test_ktlint.py
示例8: test_run_fixer
def test_run_fixer(self):
tool = Pytype(self.problems, {'fixer': True}, root_dir)
original = read_file(self.fixtures[1])
tool.execute_fixer(self.fixtures)
updated = read_and_restore_file(self.fixtures[1], original)
assert original != updated, 'File content should change.'
self.assertEqual(0, len(self.problems.all()),
'No errors should be recorded')
开发者ID:markstory,项目名称:lint-review,代码行数:10,代码来源:test_pytype.py
示例9: test_execute_fixer
def test_execute_fixer(self):
tool = Remarklint(self.problems, {'fixer': True}, root_dir)
original = read_file(self.fixtures[1])
tool.execute_fixer(self.fixtures)
tool.process_files(self.fixtures)
updated = read_and_restore_file(self.fixtures[1], original)
assert original != updated, 'File content should change.'
self.assertEqual(1, len(self.problems.all()),
'Fewer errors should be recorded')
开发者ID:markstory,项目名称:lint-review,代码行数:11,代码来源:test_remarklint.py
示例10: test_execute_fixer__python3
def test_execute_fixer__python3(self):
options = {'fixer': True, 'python': 3}
tool = Pep8(self.problems, options, root_dir)
original = read_file(self.fixtures[1])
tool.execute_fixer(self.fixtures)
updated = read_and_restore_file(self.fixtures[1], original)
assert original != updated, 'File content should change.'
self.assertEqual(0, len(self.problems.all()),
'No errors should be recorded')
开发者ID:markstory,项目名称:lint-review,代码行数:11,代码来源:test_pep8.py
示例11: test_execute_fixer
def test_execute_fixer(self):
fixture = self.fixtures[1]
tool = Stylelint(self.problems, {
'config': 'tests/fixtures/stylelint/stylelintrc.json',
'fixer': True,
}, root_dir)
original = read_file(fixture)
tool.execute_fixer([fixture])
updated = read_and_restore_file(fixture, original)
assert original != updated, 'File content should change.'
开发者ID:markstory,项目名称:lint-review,代码行数:11,代码来源:test_stylelint.py
示例12: test_execute_fixer__fewer_problems_remain
def test_execute_fixer__fewer_problems_remain(self):
tool = Pep8(self.problems, {'fixer': True}, root_dir)
# The fixture file can have all problems fixed by autopep8
original = read_file(self.fixtures[1])
tool.execute_fixer(self.fixtures)
tool.process_files(self.fixtures)
read_and_restore_file(self.fixtures[1], original)
self.assertGreaterEqual(len(self.problems.all()), 0,
'Most errors should be fixed')
开发者ID:markstory,项目名称:lint-review,代码行数:11,代码来源:test_pep8.py
示例13: test_execute_fixer__fewer_problems_remain
def test_execute_fixer__fewer_problems_remain(self):
tool = Puppet(self.problems, {'fixer': True}, root_dir)
# The fixture file should have fixable problems fixed
original = read_file(self.fixtures[1])
tool.execute_fixer(self.fixtures)
tool.process_files(self.fixtures)
read_and_restore_file(self.fixtures[1], original)
self.assertEqual(1, len(self.problems.all()),
'Most errors should be fixed')
self.assertIn('autoload module layout', self.problems.all()[0].body)
开发者ID:markstory,项目名称:lint-review,代码行数:12,代码来源:test_puppet.py
示例14: test_execute_fixer__fewer_problems_remain
def test_execute_fixer__fewer_problems_remain(self):
tool = Rubocop(self.problems, {'fixer': True}, root_dir)
# The fixture file can have all problems fixed by rubocop
original = read_file(self.fixtures[1])
tool.execute_fixer(self.fixtures)
tool.process_files(self.fixtures)
read_and_restore_file(self.fixtures[1], original)
self.assertEqual(1, len(self.problems.all()),
'Most errors should be fixed')
self.assertIn('too long', self.problems.all()[0].body)
开发者ID:markstory,项目名称:lint-review,代码行数:12,代码来源:test_rubocop.py
示例15: test_execute_fixer
def test_execute_fixer(self):
tool = Eslint(self.problems, {
'config': 'tests/fixtures/eslint/recommended_config.json',
'fixer': True,
}, root_dir)
original = read_file(FILE_WITH_FIXER_ERRORS)
tool.execute_fixer([FILE_WITH_FIXER_ERRORS])
updated = read_and_restore_file(FILE_WITH_FIXER_ERRORS, original)
assert original != updated, 'File content should change.'
self.assertEqual(0, len(self.problems.all()),
'No errors should be recorded')
开发者ID:markstory,项目名称:lint-review,代码行数:12,代码来源:test_eslint.py
示例16: _clone_define
def _clone_define(self, filebase):
"""Take the valid output xml and attempt to define it on the
connection to ensure we don't get any errors"""
outfile = os.path.join(clonexml_dir, filebase + "-out.xml")
outxml = tests.read_file(outfile)
vm = None
try:
vm = conn.defineXML(outxml)
finally:
if vm:
vm.undefine()
开发者ID:paradox12,项目名称:python-virtinst,代码行数:12,代码来源:clonetest.py
示例17: test_process_files__missing_plugin
def test_process_files__missing_plugin(self):
tool = Remarklint(self.problems, {'fixer': True}, root_dir)
config = 'tests/fixtures/remarklint/.remarkrc'
original = read_file(config)
with open(config, 'w') as f:
f.write('{"plugins": ["unknown-preset"]}')
tool.process_files([self.fixtures[1]])
with open(config, 'w') as f:
f.write(original)
problems = self.problems.all()
self.assertEqual(1, len(problems), 'Should have an error')
self.assertIn('unknown-preset', problems[0].body)
开发者ID:markstory,项目名称:lint-review,代码行数:14,代码来源:test_remarklint.py
示例18: test_way02
def test_way02(self):
"""
Try to pickle and unpickle the result object
"""
import pickle
api = overpy.Overpass()
result = api.parse_json(read_file("json/way-02.json"))
self._test_way02(result)
# do pickle and unpickle
result_string = pickle.dumps(result)
new_result = pickle.loads(result_string)
# test new result
self._test_way02(new_result)
开发者ID:DinoTools,项目名称:python-overpy,代码行数:14,代码来源:test_result.py
示例19: test_execute_fixer__options
def test_execute_fixer__options(self):
tool = Pep8(self.problems, {
'fixer': True,
'max-line-length': 120,
'exclude': 'W201'
}, root_dir)
original = read_file(self.fixtures[1])
tool.execute_fixer(self.fixtures)
updated = read_and_restore_file(self.fixtures[1], original)
assert original != updated, 'File content should change.'
self.assertEqual(0, len(self.problems.all()),
'No errors should be recorded')
开发者ID:markstory,项目名称:lint-review,代码行数:14,代码来源:test_pep8.py
示例20: test_execute_fixer__no_problems_remain
def test_execute_fixer__no_problems_remain(self):
tool = Eslint(self.problems, {
'config': 'tests/fixtures/eslint/recommended_config.json',
'fixer': True
}, root_dir)
# The fixture file can have all problems fixed by eslint
original = read_file(FILE_WITH_FIXER_ERRORS)
tool.execute_fixer([FILE_WITH_FIXER_ERRORS])
tool.process_files([FILE_WITH_FIXER_ERRORS])
read_and_restore_file(FILE_WITH_FIXER_ERRORS, original)
self.assertEqual(0, len(self.problems.all()),
'All errors should be autofixed')
开发者ID:markstory,项目名称:lint-review,代码行数:14,代码来源:test_eslint.py
注:本文中的tests.read_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论