Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions test/t/unit/test_unit_expand_glob.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import unicodedata

import pytest

from conftest import assert_bash_exec, bash_env_saved


def normalize(string):
# Applies "canonical decomposition", so might make errors look weird?
# The alternative is probably `NFC` which composes together some of
# the characters again.
# See https://docs.python.org/3/library/unicodedata.html#unicodedata.normalize
return unicodedata.normalize("NFD", string)


@pytest.mark.bashcomp(
cmd=None,
cwd="_filedir",
Expand All @@ -22,14 +32,15 @@ def functions(self, bash):

def test_match_all(self, bash, functions):
output = assert_bash_exec(bash, "__tester '*'", want_output=True)
assert (
output.strip()
== "<a b><a$b><a&b><a'b><ab><aé><brackets><dotdot><ext>"
assert normalize(output.strip()) == normalize(
"<a b><a$b><a&b><a'b><ab><aé><brackets><dotdot><ext>"
)

def test_match_pattern(self, bash, functions):
output = assert_bash_exec(bash, "__tester 'a*'", want_output=True)
assert output.strip() == "<a b><a$b><a&b><a'b><ab><aé>"
assert normalize(output.strip()) == normalize(
"<a b><a$b><a&b><a'b><ab><aé>"
)

def test_match_unmatched(self, bash, functions):
output = assert_bash_exec(
Expand All @@ -51,7 +62,9 @@ def test_protect_from_noglob(self, bash, functions):
with bash_env_saved(bash, functions) as bash_env:
bash_env.set("noglob", True)
output = assert_bash_exec(bash, "__tester 'a*'", want_output=True)
assert output.strip() == "<a b><a$b><a&b><a'b><ab><aé>"
assert normalize(output.strip()) == normalize(
"<a b><a$b><a&b><a'b><ab><aé>"
)

def test_protect_from_failglob(self, bash, functions):
with bash_env_saved(bash) as bash_env:
Expand Down Expand Up @@ -83,4 +96,6 @@ def test_protect_from_GLOBIGNORE(self, bash, functions):
bash_env.save_shopt("dotglob")
bash_env.write_variable("GLOBIGNORE", "*")
output = assert_bash_exec(bash, "__tester 'a*'", want_output=True)
assert output.strip() == "<a b><a$b><a&b><a'b><ab><aé>"
assert normalize(output.strip()) == normalize(
"<a b><a$b><a&b><a'b><ab><aé>"
)
Loading