Coverage for /pythoncovmergedfiles/medio/medio/src/gitpython/fuzzing/fuzz-targets/utils.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

2 statements  

1import atheris # pragma: no cover 

2import os # pragma: no cover 

3from typing import List # pragma: no cover 

4 

5 

6@atheris.instrument_func 

7def is_expected_exception_message(exception: Exception, error_message_list: List[str]) -> bool: # pragma: no cover 

8 """ 

9 Checks if the message of a given exception matches any of the expected error messages, case-insensitively. 

10 

11 Args: 

12 exception (Exception): The exception object raised during execution. 

13 error_message_list (List[str]): A list of error message substrings to check against the exception's message. 

14 

15 Returns: 

16 bool: True if the exception's message contains any of the substrings from the error_message_list, 

17 case-insensitively, otherwise False. 

18 """ 

19 exception_message = str(exception).lower() 

20 for error in error_message_list: 

21 if error.lower() in exception_message: 

22 return True 

23 return False 

24 

25 

26@atheris.instrument_func 

27def get_max_filename_length(path: str) -> int: # pragma: no cover 

28 """ 

29 Get the maximum filename length for the filesystem containing the given path. 

30 

31 Args: 

32 path (str): The path to check the filesystem for. 

33 

34 Returns: 

35 int: The maximum filename length. 

36 """ 

37 return os.pathconf(path, "PC_NAME_MAX")