Browse Source

[test] Use the right place holder

pull/120/head
Louis 9 years ago
parent
commit
2107200e26
  1. 32
      test/test_compilation/test_compilation.py

32
test/test_compilation/test_compilation.py

@ -63,9 +63,24 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
tex = "{}.tex".format(base) tex = "{}.tex".format(base)
with open_read(control) as expectfile: with open_read(control) as expectfile:
with open_read(tex) as latexfile: with open_read(tex) as latexfile:
expected = expectfile.read().strip()
expected = expected.replace(
"@TEST_FOLDER@",
os.path.dirname(__file__),
)
expected = expected.replace(
"@DATA_FOLDER@",
subprocess.check_output(
["python", "-c", 'import patacrep, pkg_resources; print(pkg_resources.resource_filename(patacrep.__name__, "data"))'],
universal_newlines=True,
cwd=os.path.dirname(songbook),
).strip(),
)
self.assertMultiLineEqual( self.assertMultiLineEqual(
latexfile.read().strip(), latexfile.read().strip(),
expectfile.read().strip(), expected,
) )
# Check compilation # Check compilation
@ -90,18 +105,3 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
stderr=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
cwd=os.path.dirname(songbook), cwd=os.path.dirname(songbook),
) )
def assertMultiLineEqual(self, result, expected, msg=None):
"""Replace the placeholder paths with the local paths"""
expected = expected.replace(
"@TEST_FOLDER@",
os.path.dirname(__file__),
)
expected = expected.replace(
"@DATA_FOLDER@",
os.path.abspath(resource_filename(patacrep.__name__, 'data')),
)
return super().assertMultiLineEqual(result, expected, msg)

Loading…
Cancel
Save