From 7f1ac08e9626a24e2501ee8395196a0917451acb Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Fri, 10 May 2024 10:23:27 +0200 Subject: [PATCH] Add test to ensure multibyte chars work with the usage substring --- tests/scripts/multibyte_doc.sh | 10 ++++++++++ tests/test_scriptpatching.py | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/scripts/multibyte_doc.sh diff --git a/tests/scripts/multibyte_doc.sh b/tests/scripts/multibyte_doc.sh new file mode 100644 index 0000000..3191b39 --- /dev/null +++ b/tests/scripts/multibyte_doc.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +DOC="μprog - A tiny program +Usage: uprog.sh [options] + +Options: + -d --do THINGTODO Do the thing +" +"DOCOPT PARAMS" +eval "$(docopt "$@")" diff --git a/tests/test_scriptpatching.py b/tests/test_scriptpatching.py index d9feaad..7b90653 100644 --- a/tests/test_scriptpatching.py +++ b/tests/test_scriptpatching.py @@ -406,3 +406,11 @@ def test_option_after_invocation(monkeypatch, capsys): assert ( 'STDIN:4 $DOCOPT_ADD_HELP has no effect when specified after invoking docopt, ' + 'make sure to place docopt options before calling `eval "$(docopt "$@")"`.') in err + + +def test_multibyte_doc(monkeypatch, capsys, bash): + run = patch_file(monkeypatch, capsys, 'multibyte_doc.sh') + code, out, err = run(bash, 'invalid') + assert err == 'Usage: uprog.sh [options]\n' + assert code == 1 + assert out == ''