diff options
author | aa-turner <aa-turner@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2023-03-25 17:23:16 +0000 |
---|---|---|
committer | aa-turner <aa-turner@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2023-03-25 17:23:16 +0000 |
commit | 0cfafb31e894b5d8ba2f91306a6151aba615dda3 (patch) | |
tree | 23051217f095b4171504c362acefa0c83943e7e0 | |
parent | cdaf19ed84db0b73d433c9f2b6dd48acefea3cc3 (diff) | |
download | docutils-0cfafb31e894b5d8ba2f91306a6151aba615dda3.tar.gz |
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
-rw-r--r-- | docutils/test/test_CLI.py | 6 |
1 files changed, 4 insertions, 2 deletions
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) |