-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'blank-path' into develop
- Loading branch information
Showing
4 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Test the ls subcommand in the command line tool. | ||
The general functioning is already tested in test_04_cli.py, we only | ||
consider edge cases here. | ||
""" | ||
|
||
from pathlib import Path | ||
import stat | ||
from tempfile import TemporaryFile | ||
import pytest | ||
from archive import Archive | ||
from conftest import * | ||
|
||
|
||
def test_cli_ls_blank_path(tmpdir): | ||
"""Test case: archive contains a file having blanks in the path. | ||
Ref. Issue #81. | ||
""" | ||
testdata = [ | ||
DataDir(Path("base"), 0o755), | ||
DataFile(Path("base", "msg.txt"), 0o644), | ||
DataContentFile(Path("base", "path with blanks.dat"), b"", 0o600), | ||
] | ||
setup_testdata(tmpdir, testdata) | ||
archive_path = tmpdir / "archive.tar" | ||
Archive().create(archive_path, paths=[Path("base")], workdir=tmpdir) | ||
with TemporaryFile(mode="w+t", dir=tmpdir) as f: | ||
args = ["ls", str(archive_path)] | ||
callscript("archive-tool.py", args, stdout=f) | ||
f.seek(0) | ||
for entry in sorted(testdata, key=lambda e: e.path): | ||
line = f.readline().strip() | ||
fields = line.split(maxsplit=5) | ||
assert fields[0] == stat.filemode(entry.st_mode) | ||
assert fields[5] == str(entry.path) | ||
assert len(fields) == 6 | ||
assert not f.readline() |