mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 11:36:54 +00:00
testing for xml encoding checker
This commit is contained in:
parent
c0145f16cb
commit
04d965a6a5
5 changed files with 58 additions and 0 deletions
|
|
@ -0,0 +1,31 @@
|
|||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
from pre_commit_hooks.loaderon_hooks.general_hooks.check_xml_encoding import main
|
||||
from pre_commit_hooks.loaderon_hooks.tests.automatic_testing.util.test_helpers import \
|
||||
perform_test_on_file_expecting_result
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_sys_argv():
|
||||
sys.argv = []
|
||||
|
||||
# Encoding to be checked
|
||||
sys.argv.append('--encoding')
|
||||
sys.argv.append(r'<?xml version="1.0" encoding="utf-8"?>')
|
||||
yield
|
||||
|
||||
|
||||
def test_check_xml_encoding_ok():
|
||||
perform_test_on_file_expecting_result('check_xml_encoding_samples/ok.xml', main)
|
||||
|
||||
|
||||
def test_check_xml_encoding_error_1():
|
||||
perform_test_on_file_expecting_result('check_xml_encoding_samples/no_encoding.xml', main, expected_result=2)
|
||||
|
||||
|
||||
def test_check_xml_encoding_error_2():
|
||||
perform_test_on_file_expecting_result('check_xml_encoding_samples/first_line_is_empty_space.xml',
|
||||
main,
|
||||
expected_result=2)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="id" model="ir.ui.view">
|
||||
<field name="name">some.model.form.inherit</field>
|
||||
<field name="model">some.model</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<odoo>
|
||||
<data>
|
||||
<record id="id" model="ir.ui.view">
|
||||
<field name="name">some.model.form.inherit</field>
|
||||
<field name="model">some.model</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="id" model="ir.ui.view">
|
||||
<field name="name">some.model.form.inherit</field>
|
||||
<field name="model">some.model</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue