tests.test_preferred_encoding   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 14
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A test_not_ascii() 0 17 2
1
"""Collection of tests around character encodings."""
2
import codecs
3
import locale
4
import sys
5
6
import pytest
7
8
PY3 = sys.version_info[0] == 3
9
10
11
@pytest.mark.skipif(not PY3, reason='Only necessary on Python3')
12
def test_not_ascii():
13
    """Make sure that the systems preferred encoding is not `ascii`.
14
15
    Otherwise `click` is raising a RuntimeError for Python3. For a detailed
16
    description of this very problem please consult the following gist:
17
    https://gist.github.com/hackebrot/937245251887197ef542
18
19
    This test also checks that `tox.ini` explicitly copies the according
20
    system environment variables to the test environments.
21
    """
22
    try:
23
        preferred_encoding = locale.getpreferredencoding()
24
        fs_enc = codecs.lookup(preferred_encoding).name
25
    except Exception:
26
        fs_enc = 'ascii'
27
    assert fs_enc != 'ascii'
28