Skip to content
Myr

test: verify that UTF-8 is used as a fallback for decoding arguments

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Giel van Schijndel · committed by Giel van Schijndel · parent ab63d85 · Browse files · 1 file+22 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+22 added−1 removed

  • tests:+22 added−1 removed

1 file+22 added−1 removed

modified:tests/test_arguments.py+22 added-1 removed
1# -*- coding: utf-8 -*-2import pytest3import click4import sys4from click._compat import PY25from click._compat import PY2, text_type678def test_nargs_star(runner):9 @click.command()
74 unmodified lines
84 assert result.exit_code == 285 assert 'Got unexpected extra argument (bar)' in result.output868788def test_bytes_args(runner, monkeypatch):89 @click.command()90 @click.argument('arg')91 def from_bytes(arg):92 assert isinstance(arg, text_type), "UTF-8 encoded argument should be implicitly converted to Unicode"9394 # Simulate empty locale environment variables95 if PY2:96 monkeypatch.setattr(sys.stdin, 'encoding', 'ANSI_X3.4-1968')97 monkeypatch.setattr(sys, 'getfilesystemencoding', lambda: 'ANSI_X3.4-1968')98 monkeypatch.setattr(sys, 'getdefaultencoding', lambda: 'ascii')99 else:100 monkeypatch.setattr(sys.stdin, 'encoding', 'utf-8')101 monkeypatch.setattr(sys, 'getfilesystemencoding', lambda: 'utf-8')102 monkeypatch.setattr(sys, 'getdefaultencoding', lambda: 'utf-8')103104 runner.invoke(from_bytes, [u'Something outside of ASCII range: 林'.encode('UTF-8')],105 catch_exceptions=False)106107108def test_file_args(runner):109 @click.command()110 @click.argument('input', type=click.File('rb'))111 @click.argument('output', type=click.File('wb'))
208 unmodified lines