Repository navigation
Commit 0d9f2d2
committed
Skip posix path traversal test rows on a Windows filesystem
The parametrized traversal tests added in 1.4.2 run every spelling of a
traversal URI against both posixpath and ntpath, forcing os.path to
each in turn. The ntpath half works on any host, as ntpath accepts
forward slashes, but the posixpath half cannot work on Windows:
TemplateLookup.get_template() converts the configured directory with
dir_.replace(os.path.sep, posixpath.sep), so with os.path forced to
posixpath the separator sought is "/" and the directory's real
backslashes are left in place. The joined path then normalizes to
something that does not exist, and get_template() raises
TopLevelLookupException before the traversal check is ever consulted,
failing eleven cases on the Windows jobs.
The posixpath rows are now skipped when os.name is "nt". Coverage is
not lost: those rows continue to run on the Linux and macOS jobs, and
on Windows the ntpath rows exercise the check against the real
os.path rather than an emulation of it.
Only the test suite was affected. The traversal check itself is
unchanged.
Fixes: #441
Change-Id: I4cbb5f1d1793aecd1aafd288d771de596da4b88b1 parent 45a738c commit 0d9f2d2
2 files changed
Lines changed: 28 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
138 | 154 | | |
139 | 155 | | |
140 | 156 | | |
| |||
0 commit comments