Skip to content

Commit 8e7cef2

Browse files
committed
some fixes for non-utf8 environments
1 parent 3c67219 commit 8e7cef2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/helpers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def assert_equality(plot, filename):
3939
plt.close()
4040

4141
this_dir = os.path.dirname(os.path.abspath(__file__))
42-
with open(os.path.join(this_dir, filename), "r") as f:
42+
with open(os.path.join(this_dir, filename), "r", encoding="utf-8") as f:
4343
reference = f.read()
4444
assert reference == code, _unidiff_output(reference, code)
4545

@@ -52,19 +52,21 @@ def _does_compile(code):
5252
matplotlib2tikz.get_tikz_code()
5353

5454
# create a latex wrapper for the tikz
55+
# <https://tex.stackexchange.com/a/361070/13262>
5556
wrapper = """\\documentclass{{standalone}}
5657
\\usepackage[utf8]{{inputenc}}
5758
\\usepackage{{pgfplots}}
5859
\\usepgfplotslibrary{{groupplots}}
5960
\\usetikzlibrary{{shapes.arrows}}
6061
\\pgfplotsset{{compat=newest}}
62+
\\DeclareUnicodeCharacter{{2212}}{{-}}
6163
\\begin{{document}}
6264
{}
6365
\\end{{document}}""".format(
6466
code
6567
)
6668
tex_file = tmp_base + ".tex"
67-
with open(tex_file, "w") as f:
69+
with open(tex_file, "w", encoding="utf-8") as f:
6870
f.write(wrapper)
6971

7072
# change into the directory of the TeX file

0 commit comments

Comments
 (0)