def test_has_valid_extension_return_false_if_specified_extension_is_not_list( self): for extension in ['extensions', 1234, dict(extension='py')]: self.assertFalse( has_valid_extension(file_path=os.path.join( FIXTURES_DIRECTORY_PATH, 'common.py'), valid_extensions=extension))
def test_has_valid_extension_accepts_list_set_and_tuple_for_extension_argument( self): for extension in [['py'], {'py'}, ('py', )]: self.assertTrue( has_valid_extension(file_path=os.path.join( FIXTURES_DIRECTORY_PATH, 'common.py'), valid_extensions=extension))
def has_valid_extension(self, file_path: str = None) -> bool: """Check if given file has specified extension. Parameters ---------- file_path: str Path of file to check for having valid extension Returns ------- status: bool True if file has valid extension, false otherwise """ if not file_path: return False return has_valid_extension(file_path=file_path, valid_extensions=[self.__valid_file_extensions])
def test_has_valid_extension_return_true_if_empty_extension_specified( self): self.assertTrue( has_valid_extension(file_path=os.path.join(FIXTURES_DIRECTORY_PATH, 'common.py'), valid_extensions=[]))