From 0cfafb31e894b5d8ba2f91306a6151aba615dda3 Mon Sep 17 00:00:00 2001 From: aa-turner Date: Sat, 25 Mar 2023 17:23:16 +0000 Subject: Use absolute paths in ``test_CLI`` When running tests in working directories other than ``docutils/test``, the tests fail as the expected files cannot be opened from the relative ``./data`` path. This change uses the defined ``DATA_ROOT`` constant so that the tests pass regardless of working directory. We also take the opportunity to explicitly specify the encoding with which to open the file, avoiding platform-dependent behaviour. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9330 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/test/test_CLI.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'docutils') diff --git a/docutils/test/test_CLI.py b/docutils/test/test_CLI.py index f88e3e646..2d058e3e4 100644 --- a/docutils/test/test_CLI.py +++ b/docutils/test/test_CLI.py @@ -91,7 +91,8 @@ class CliTests(unittest.TestCase): # collect help text output = self.get_help_text('rst2html', core.rst2html) # compare to stored version - with open('data/help/rst2html.txt') as samplefile: + rst2html_txt = os.path.join(DATA_ROOT, 'help/rst2html.txt') + with open(rst2html_txt, encoding='utf-8') as samplefile: expected = samplefile.read() if expected != output: print_mismatch(expected, output) @@ -100,7 +101,8 @@ class CliTests(unittest.TestCase): # collect help text output = self.get_help_text('rst2latex', core.rst2latex) # compare to stored version - with open('data/help/rst2latex.txt') as samplefile: + rst2latex_txt = os.path.join(DATA_ROOT, 'help/rst2latex.txt') + with open(rst2latex_txt, encoding='utf-8') as samplefile: expected = samplefile.read() if expected != output: print_mismatch(expected, output) -- cgit v1.2.1