Loading tests/bst_parser_test/bst_parser_test.py +2 −2 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ from __future__ import unicode_literals from six.moves import zip_longest from pybtex.bibtex import bst from ..utils import read_file from ..utils import get_data test_data = ( 'plain', Loading @@ -15,7 +15,7 @@ test_data = ( def check_bst_parser(dataset_name): module = __import__('tests.bst_parser_test.{0}'.format(dataset_name), globals(), locals(), 'bst') correct_result = module.bst bst_data = read_file(dataset_name + '.bst') bst_data = get_data(dataset_name + '.bst') actual_result = bst.parse_string(bst_data) for correct_element, actual_element in zip_longest(actual_result, correct_result): Loading tests/general_engine_test.py +6 −6 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ from shutil import rmtree from tempfile import mkdtemp from pybtex import errors, io from .utils import diff, read_file from .utils import diff, get_data @contextmanager Loading @@ -23,7 +23,7 @@ def cd_tempdir(): def copy_file(filename): data = read_file(filename) data = get_data(filename) with io.open_unicode(filename, 'w') as data_file: data_file.write(data) Loading Loading @@ -54,7 +54,7 @@ def check_format_from_string(engine, filenames): if '.aux' in filenames_by_suffix: from io import StringIO from pybtex import auxfile aux_contents = StringIO(read_file(filenames_by_suffix['.aux'])) aux_contents = StringIO(get_data(filenames_by_suffix['.aux'])) auxdata = auxfile.parse_file(aux_contents) citations = auxdata.citations style = auxdata.style Loading @@ -65,11 +65,11 @@ def check_format_from_string(engine, filenames): with cd_tempdir(): copy_file(filenames_by_suffix['.bst']) bib_name = posixpath.splitext(filenames_by_suffix['.bib'])[0] bib_string = read_file(filenames_by_suffix['.bib']) bib_string = get_data(filenames_by_suffix['.bib']) with errors.capture(): # FIXME check error messages result = engine.format_from_string(bib_string, style=style, citations=citations) correct_result_name = '{0}_{1}.{2}.bbl'.format(bib_name, style, engine_name) correct_result = read_file(correct_result_name) correct_result = get_data(correct_result_name) assert result == correct_result, diff(correct_result, result) Loading Loading @@ -97,7 +97,7 @@ def check_make_bibliography(engine, filenames): with io.open_unicode(result_name) as result_file: result = result_file.read() correct_result_name = '{0}_{1}.{2}.bbl'.format(bib_name, bst_name, engine_name) correct_result = read_file(correct_result_name) correct_result = get_data(correct_result_name) assert result == correct_result, diff(correct_result, result) Loading tests/utils.py +1 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,6 @@ def diff(src, dst): return '\n'.join(unified_diff(src.splitlines(), dst.splitlines())) def read_file(filename, package='tests.data'): def get_data(filename, package='tests.data'): return pkgutil.get_data(package, filename).decode('UTF-8') Loading
tests/bst_parser_test/bst_parser_test.py +2 −2 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ from __future__ import unicode_literals from six.moves import zip_longest from pybtex.bibtex import bst from ..utils import read_file from ..utils import get_data test_data = ( 'plain', Loading @@ -15,7 +15,7 @@ test_data = ( def check_bst_parser(dataset_name): module = __import__('tests.bst_parser_test.{0}'.format(dataset_name), globals(), locals(), 'bst') correct_result = module.bst bst_data = read_file(dataset_name + '.bst') bst_data = get_data(dataset_name + '.bst') actual_result = bst.parse_string(bst_data) for correct_element, actual_element in zip_longest(actual_result, correct_result): Loading
tests/general_engine_test.py +6 −6 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ from shutil import rmtree from tempfile import mkdtemp from pybtex import errors, io from .utils import diff, read_file from .utils import diff, get_data @contextmanager Loading @@ -23,7 +23,7 @@ def cd_tempdir(): def copy_file(filename): data = read_file(filename) data = get_data(filename) with io.open_unicode(filename, 'w') as data_file: data_file.write(data) Loading Loading @@ -54,7 +54,7 @@ def check_format_from_string(engine, filenames): if '.aux' in filenames_by_suffix: from io import StringIO from pybtex import auxfile aux_contents = StringIO(read_file(filenames_by_suffix['.aux'])) aux_contents = StringIO(get_data(filenames_by_suffix['.aux'])) auxdata = auxfile.parse_file(aux_contents) citations = auxdata.citations style = auxdata.style Loading @@ -65,11 +65,11 @@ def check_format_from_string(engine, filenames): with cd_tempdir(): copy_file(filenames_by_suffix['.bst']) bib_name = posixpath.splitext(filenames_by_suffix['.bib'])[0] bib_string = read_file(filenames_by_suffix['.bib']) bib_string = get_data(filenames_by_suffix['.bib']) with errors.capture(): # FIXME check error messages result = engine.format_from_string(bib_string, style=style, citations=citations) correct_result_name = '{0}_{1}.{2}.bbl'.format(bib_name, style, engine_name) correct_result = read_file(correct_result_name) correct_result = get_data(correct_result_name) assert result == correct_result, diff(correct_result, result) Loading Loading @@ -97,7 +97,7 @@ def check_make_bibliography(engine, filenames): with io.open_unicode(result_name) as result_file: result = result_file.read() correct_result_name = '{0}_{1}.{2}.bbl'.format(bib_name, bst_name, engine_name) correct_result = read_file(correct_result_name) correct_result = get_data(correct_result_name) assert result == correct_result, diff(correct_result, result) Loading
tests/utils.py +1 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,6 @@ def diff(src, dst): return '\n'.join(unified_diff(src.splitlines(), dst.splitlines())) def read_file(filename, package='tests.data'): def get_data(filename, package='tests.data'): return pkgutil.get_data(package, filename).decode('UTF-8')