[TIP] I have some data files I want to use in my tests -- how do I specify where they are?

Olemis Lang olemis at gmail.com
Mon Dec 21 08:17:00 PST 2009

On Mon, Dec 21, 2009 at 10:01 AM, Matthew Wilson <matt at tplus1.com> wrote:
> On Mon, Dec 21, 2009 at 8:02 AM, Olemis Lang <olemis at gmail.com> wrote:
>> If the package is not in the local file system (e.g. it's packaged
>> inside an EGG file or whatever ) then this does not work. My
>> suggestion is :
>>  - Place data files inside `tests/data`
>>  - Add it to `package_data` in `setup.py`
>>  - In your test code use pkg_resources.(resource_filename |
>> resource_stream | resource_string)
>>    to load the data .
> Is there some way to do this with just the stuff in the standard library?

I suppose that you cannot if Py<=2.5 . That's exactly why settoptools
was written once upon a time . It seems that stdlib module
`distribute` will provide a way to do this in Py>=? , but I don't know
the details (that's why I am Cc-ing to P.J. Eby and Tarek Ziadé ;o)



Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Implemented common `/rpc` path. HTTP 415 error if no match found.  -

More information about the testing-in-python mailing list