kakada wrote: > Actually, what I want is creating a kind of file that is just located in > memory not file system. > I want to have a filename for my convert(inputFileName, outputFileName) > How can I get filename? > doing: > fin.name() is impossible!
Rewrite convert so it takes file-like objects as arguments rather than file names. Then you can pass StringIO objects for input and output in your unittests. Alternately you might want to write convert so it can take *either* a file name or an open file as an argument. Here is a snippet from a function that does that (ElementTree.parse()): def parse(self, source, parser=None): if not hasattr(source, "read"): source = open(source, "rb") > All above, I want to test it in unittest. Good idea! Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor