Raise error instead of trying to fix bad names.

Thanks for the advice, @radl97
This commit is contained in:
Andras Schmelczer 2022-09-17 20:19:23 +02:00
parent 04c3486b83
commit ec64a0b5f1
No known key found for this signature in database
GPG key ID: 0EA1BC97D0AB076E
4 changed files with 23 additions and 3 deletions

View file

@ -24,6 +24,20 @@ def test_uninitialized() -> None:
LargeFileS3("test-file")
def test_bad_file_name() -> None:
with pytest.raises(ValueError):
LargeFileS3("../no-no", cache_only_mode=True)
with pytest.raises(ValueError):
LargeFileS3("is this wrong?", cache_only_mode=True)
with pytest.raises(FileNotFoundError):
LargeFileS3("!378378_fer-ef", cache_only_mode=True) # this should work
with pytest.raises(FileNotFoundError):
LargeFileS3("3", cache_only_mode=True) # this should work
def test_bad_file_modes() -> None:
with pytest.raises(ValueError):
LargeFileS3("test-file", "w", version=3)