def test_file_walk(self, testfs_fat_stable1): """ Test if file_walk works in a simple case """ for img_path in testfs_fat_stable1: print("IMAGE:", img_path) with open(img_path, 'rb') as img_stream: # create FileSlack object fatfs = FileSlack(img_stream) # turn 'onedirectory' into DIR_ENTRY entry = fatfs.fatfs.find_file("onedirectory") result = [] for file_entry in fatfs._file_walk(entry): result.append(file_entry) # Assume that we only found 2 file assert len(result) == 2 # unpack that file into result result = result[0] # check for file attibutes assert result.parsed.name == b'AFILEI~1' assert result.parsed.extension == b'TXT' assert not result.parsed.attributes.unused assert not result.parsed.attributes.device assert result.parsed.attributes.archive assert not result.parsed.attributes.subDirectory assert not result.parsed.attributes.volumeLabel assert not result.parsed.attributes.system assert not result.parsed.attributes.hidden assert not result.parsed.attributes.readonly assert result.parsed.fileSize == 11
def test_file_walk_nondir(self, testfs_fat_stable1): """ Test if file_walk fails if given DirEntry is not a directory """ for img_path in testfs_fat_stable1: with open(img_path, 'rb') as img_stream: # create FileSlack object fatfs = FileSlack(img_stream) entry = fatfs.fatfs.find_file("another") next_file = fatfs._file_walk(entry) with pytest.raises(AssertionError): next(next_file)