Skip to content

Commit

Permalink
XMLBearTest: Add get_testfile_path
Browse files Browse the repository at this point in the history
... to create absolute test-file paths used during tests. This commit
merges the duplicated test-file-path-functionality.
  • Loading branch information
Makman2 committed Sep 28, 2017
1 parent f95fb76 commit b864b6c
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions tests/xml2/XMLBearTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
from coala_utils.ContextManagers import prepare_file


def load_testdata(filename):
path = os.path.join(os.path.dirname(__file__),
def get_testfile_path(filename):
return os.path.join(os.path.dirname(__file__),
'test_files',
filename)


def load_testdata(filename):
path = get_testfile_path(filename)
with open(path) as f:
return f.read()

Expand All @@ -36,16 +40,9 @@ def load_testdata(filename):
<a>hey and hi</a>
"""

dtd_file = os.path.join(os.path.dirname(__file__),
'test_files',
'note.dtd')

schema_file = os.path.join(os.path.dirname(__file__),
'test_files',
'note.xsd')
relaxng_file = os.path.join(os.path.dirname(__file__),
'test_files',
'note.rng')
dtd_file_path = get_testfile_path('note.dtd')
schema_file_path = get_testfile_path('note.xsd')
relaxng_file_path = get_testfile_path('note.rng')

valid_xml_path = load_testdata('note.xml')
valid_xml_url = load_testdata('concept-valid.xml')
Expand All @@ -66,14 +63,14 @@ def load_testdata(filename):
XMLBear,
valid_files=(valid_xml_path,),
invalid_files=(invalid_xml_schema,),
settings={'xml_schema': schema_file},
settings={'xml_schema': schema_file_path},
tempfile_kwargs={'suffix': '.xml'})

XMLBearDTDPathTest = verify_local_bear(
XMLBear,
valid_files=(valid_xml_path,),
invalid_files=(invalid_xml_dtd,),
settings={'xml_dtd': dtd_file},
settings={'xml_dtd': dtd_file_path},
tempfile_kwargs={'suffix': '.xml'})

XMLBearDTDUrlTest = verify_local_bear(
Expand All @@ -87,7 +84,7 @@ def load_testdata(filename):
XMLBear,
valid_files=(valid_xml_path,),
invalid_files=(invalid_xml_relaxng,),
settings={'xml_relaxng': relaxng_file},
settings={'xml_relaxng': relaxng_file_path},
tempfile_kwargs={'suffix': '.xml'})


Expand Down

0 comments on commit b864b6c

Please sign in to comment.