-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #609 from Ravencentric/getinfo
feat: add `getinfo()`
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from py7zr import SevenZipFile | ||
|
||
testdata_path = os.path.join(os.path.dirname(__file__), "data") | ||
|
||
|
||
def test_getinfo_file(): | ||
with SevenZipFile(os.path.join(testdata_path, "copy.7z")) as archive: | ||
member = archive.getinfo("test1.txt") | ||
assert member.filename == "test1.txt" | ||
assert member.is_directory is False | ||
|
||
|
||
def test_getinfo_dir(): | ||
with SevenZipFile(os.path.join(testdata_path, "copy.7z")) as archive: | ||
member = archive.getinfo("test") | ||
assert member.filename == "test" | ||
assert member.is_directory is True | ||
|
||
|
||
def test_getinfo_file_with_trailing_slash(): | ||
with SevenZipFile(os.path.join(testdata_path, "copy.7z")) as archive: | ||
member = archive.getinfo("test1.txt/") | ||
assert member.filename == "test1.txt" | ||
assert member.is_directory is False | ||
|
||
|
||
def test_getinfo_dir_with_trailing_slash(): | ||
with SevenZipFile(os.path.join(testdata_path, "copy.7z")) as archive: | ||
member = archive.getinfo("test/") | ||
assert member.filename == "test" | ||
assert member.is_directory is True | ||
|
||
|
||
def test_getinfo_missing_member(): | ||
with pytest.raises(KeyError): | ||
with SevenZipFile(os.path.join(testdata_path, "copy.7z")) as archive: | ||
archive.getinfo("doesn't exist") |