diff --git a/dissect/ntfs/exceptions.py b/dissect/ntfs/exceptions.py index d5b2371..ae560af 100644 --- a/dissect/ntfs/exceptions.py +++ b/dissect/ntfs/exceptions.py @@ -14,7 +14,7 @@ class FilenameNotAvailableError(Error): pass -class FileNotFoundError(Error): +class FileNotFoundError(Error, FileNotFoundError): pass @@ -22,7 +22,11 @@ class MftNotAvailableError(Error): pass -class NotADirectoryError(Error): +class IsADirectoryError(Error, IsADirectoryError): + pass + + +class NotADirectoryError(Error, NotADirectoryError): pass diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py new file mode 100644 index 0000000..6f1d857 --- /dev/null +++ b/tests/test_exceptions.py @@ -0,0 +1,19 @@ +import pytest + +from dissect.ntfs import exceptions + + +@pytest.mark.parametrize( + "exc, std", + [ + (exceptions.FileNotFoundError, FileNotFoundError), + (exceptions.IsADirectoryError, IsADirectoryError), + (exceptions.NotADirectoryError, NotADirectoryError), + ], +) +def test_filesystem_error_subclass(exc: exceptions.Error, std: Exception) -> None: + assert issubclass(exc, std) + assert isinstance(exc(), std) + + with pytest.raises(std): + raise exc()