Debian Codegraph @

testsuite/trimslash_test.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 # Python rewrite of testsuite/trimslash.test.
3 #
4 # Test the tiny trimslash helper which strips trailing slashes from paths.
5
6 import subprocess
7
8 from rsyncfns import TOOLDIR, test_fail
9
10
11 INPUTS = [
12 "/usr/local/bin",
13 "/usr/local/bin/",
14 "/usr/local/bin///",
15 "//a//",
16 "////",
17 "/Users/Weird Macintosh Name/// Ooh, translucent plastic/",
18 ]
19
20 EXPECTED = """\
21 /usr/local/bin
22 /usr/local/bin
23 /usr/local/bin
24 //a
25 /
26 /Users/Weird Macintosh Name/// Ooh, translucent plastic
27 """
28
29 proc = subprocess.run(
30 [str(TOOLDIR / 'trimslash'), *INPUTS],
31 capture_output=True, text=True,
32 )
33 if proc.returncode != 0:
34 test_fail(f"trimslash exited {proc.returncode}\nstderr:\n{proc.stderr}")
35
36 if proc.stdout != EXPECTED:
37 test_fail(
38 "trimslash output did not match expected.\n"
39 f"--- expected ---\n{EXPECTED}"
40 f"--- got ---\n{proc.stdout}"
41 )