[Tutor] Writing to the file system and verify the files written out.

Steven D'Aprano steve at pearwood.info
Fri Apr 15 09:20:40 CEST 2011


Becky Mcquilling wrote:

>         dir_list = os.listdir(self.dirname)
>         dir_set = set()
>         for file in dir_list:
>             dir_set.add(file)
>         self.assertEqual(dir_list, text_files, "The filelist is not equal")

You're comparing a list of file names to a set of file names. They will 
never match, even if they have the same content.

Try this instead:

dir_set = set(os.listdir(self.dirname))
self.assertEqual(dir_set, text_files, "The filelist is not equal")



-- 
Steven


More information about the Tutor mailing list