本文整理汇总了Python中tests.read_file函数的典型用法代码示例。如果您正苦于以下问题:Python read_file函数的具体用法?Python read_file怎么用?Python read_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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')
示例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)
示例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")
示例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')
示例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)
示例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')
示例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')
示例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')
示例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')
示例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.'
示例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')
示例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)
示例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)
示例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')