[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
Mon Dec 21 07:01:48 PST 2009

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?

W. Matthew Wilson
matt at tplus1.com

More information about the testing-in-python mailing list