Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7632f0b

Browse files
authored
Merge pull request astropy#33 from astrofrog/ascii-locale
Add a test configuration with a default ASCII locale
2 parents 2f7d600 + 462dea4 commit 7632f0b

9 files changed

+54
-3
lines changed

.travis.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,24 @@ env:
3333
- PYTHON_VERSION=3.5 SPHINX_VERSION=1.5
3434
- PYTHON_VERSION=3.6 SPHINX_VERSION=1.6 CONDA_CHANNELS="conda-forge"
3535
- PYTHON_VERSION=3.6 SPHINX_VERSION=dev CONDA_DEPENDENCIES="setuptools cython pytest-cov"
36+
- PYTHON_VERSION=2.7 LOCALE=C
37+
- PYTHON_VERSION=3.6 LOCALE=C
3638
global:
39+
- LOCALE=default
3740
- CONDA_DEPENDENCIES="setuptools sphinx cython pytest-cov"
3841
- PIP_DEPENDENCIES="coveralls"
3942
- HOMEBREW_NO_AUTO_UPDATE=1
4043

4144
before_install:
45+
46+
# Make sure that things work even if the locale is set to C (which effectively means ASCII).
47+
# Some of the input rst files have unicode characters and we need to deal with this gracefully.
48+
- if [[ $LOCALE == C ]]; then
49+
export LC_CTYPE=C;
50+
export LC_ALL=C;
51+
export LANG=C;
52+
fi
53+
4254
- if [[ $TRAVIS_OS_NAME == osx ]]; then brew install graphviz; fi
4355

4456
install:

sphinx_automodapi/automodsumm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class members that are inherited from a base class. This value can be
8686
import inspect
8787
import os
8888
import re
89+
import io
8990

9091
from sphinx.ext.autosummary import Autosummary
9192
from sphinx.ext.inheritance_diagram import InheritanceDiagram
@@ -305,7 +306,7 @@ def automodsumm_to_autosummary_lines(fn, app):
305306

306307
fullfn = os.path.join(app.builder.env.srcdir, fn)
307308

308-
with open(fullfn) as fr:
309+
with io.open(fullfn, encoding='utf8') as fr:
309310
# Note: we use __name__ here instead of just writing the module name in
310311
# case this extension is bundled into another package
311312
from . import automodapi
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Non-ASCII characters
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Ceçi est un exemple qui inclus des charactères non-ASCII
2+
3+
.. automodapi:: sphinx_automodapi.tests.example_module.functions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
add
2+
===
3+
4+
.. currentmodule:: sphinx_automodapi.tests.example_module.functions
5+
6+
.. autofunction:: add
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
multiply
2+
========
3+
4+
.. currentmodule:: sphinx_automodapi.tests.example_module.functions
5+
6+
.. autofunction:: multiply
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Ceçi est un exemple qui inclus des charactères non-ASCII
2+
3+
4+
sphinx_automodapi.tests.example_module.functions Module
5+
-------------------------------------------------------
6+
7+
.. automodule:: sphinx_automodapi.tests.example_module.functions
8+
9+
Functions
10+
^^^^^^^^^
11+
12+
.. automodsumm:: sphinx_automodapi.tests.example_module.functions
13+
:functions-only:
14+
:toctree: api
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. currentmodule:: sphinx_automodapi.tests.example_module.functions
2+
3+
.. autosummary::
4+
:toctree: api
5+
6+
add
7+
multiply

sphinx_automodapi/tests/test_cases.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# We store different cases in the cases sub-directory of the tests directory
55

66
import os
7+
import io
78
import sys
89
import glob
910
import shutil
@@ -109,6 +110,6 @@ def test_run_full_case(tmpdir, case_dir):
109110
path_relative = os.path.relpath(path_reference, output_dir)
110111
path_actual = os.path.join(docs_dir, path_relative)
111112
assert os.path.exists(path_actual)
112-
actual = open(path_actual).read()
113-
reference = open(path_reference).read()
113+
actual = io.open(path_actual, encoding='utf8').read()
114+
reference = io.open(path_reference, encoding='utf8').read()
114115
assert actual.strip() == reference.strip()

0 commit comments

Comments
 (0)