[TIP] I have some data files I want to use in my tests -- how do I specify where they are?
Matthew Wilson
matt at tplus1.com
Sun Dec 20 08:43:19 PST 2009
I'm writing some code to extract and yield some attachments out of
email messages. I have a file named email_parsers.py and another file
in a tests/ subdirectory named test_email_parsers.py
I have a few email messages saved as text files. These files are in
that tests/ directory.
In my test code, I want to know how to open those email files. Should
I use something like os.dirname(__file__)?
I know I won't always run my tests from the tests/ subdirectory
TIA!
Matt
--
W. Matthew Wilson
matt at tplus1.com
http://tplus1.com
More information about the testing-in-python
mailing list