Skip to content

Commit

Permalink
Tests: replace ls with find for system command
Browse files Browse the repository at this point in the history
  • Loading branch information
ghantoos committed Nov 30, 2024
1 parent 7779cf2 commit ea43879
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,24 @@ def test_14_path_completion_tilda(self):

# test dir list
p_dir_list = subprocess.Popen(
"ls -a -d ~/*/", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE
"find . -maxdepth 1 -type d -printf '%f/\n'",
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
)
stdout_p_dir_list = p_dir_list.stdout
expected = stdout_p_dir_list.read().decode("utf8").strip().split()
# Normalize expected to relative paths
expected = [f"{os.path.relpath(path, home_dir)}/" for path in expected]
expected = set(expected)
expected.discard("./")

self.child.sendline("cd ~/\t\t")
self.child.expect(PROMPT)
output = (
self.child.before.decode("utf8").strip().split("\n", 1)[1].strip().split()
)
output = set(output)

self.assertEqual(expected, output)

# cleanup
Expand All @@ -94,16 +100,15 @@ def test_15_file_completion_tilda(self):

# test file list
p_file_list = subprocess.Popen(
"ls -a --indicator-style=slash ~/",
"find . -maxdepth 1 -printf '%P%y\n' | sed 's|d$|/|;s|f$||'",
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
)
stdout_p_file_list = p_file_list.stdout
expected = stdout_p_file_list.read().decode("utf8").strip().split()
expected = set(expected)
expected.discard("./")
expected.discard("../")
expected.discard("/")

self.child.sendline("ls ~/\t\t")
self.child.expect(PROMPT)
Expand Down Expand Up @@ -135,16 +140,15 @@ def test_16_file_completion_with_arg(self):

# test file list
p_file_list = subprocess.Popen(
"ls -a --indicator-style=slash ~/",
"find . -maxdepth 1 -printf '%P%y\n' | sed 's|d$|/|;s|f$||'",
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
)
stdout_p_file_list = p_file_list.stdout
expected = stdout_p_file_list.read().decode("utf8").strip().split()
expected = set(expected)
expected.discard("./")
expected.discard("../")
expected.discard("/")

self.child.sendline("ls -l ~/\t\t")
self.child.expect(PROMPT)
Expand Down

0 comments on commit ea43879

Please sign in to comment.