diff --git a/dissect/fat/exceptions.py b/dissect/fat/exceptions.py index 600c02d..8c84849 100644 --- a/dissect/fat/exceptions.py +++ b/dissect/fat/exceptions.py @@ -30,9 +30,13 @@ class InvalidDirectoryError(Error): pass -class FileNotFoundError(Error): +class FileNotFoundError(Error, FileNotFoundError): 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..329d773 --- /dev/null +++ b/tests/test_exceptions.py @@ -0,0 +1,19 @@ +import pytest + +from dissect.fat 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()