[TIP] data files for testing

Marius Gedminas marius at gedmin.as
Sat Dec 17 16:50:36 PST 2011

On Sat, Dec 17, 2011 at 09:44:48PM +0000, Andrea Crotti wrote:
> Suppose I have some directories and files that I only use with my unit
> tests,
> now how should I address them?
> I mean if for example I have
> package
>  - test
>    + fake_directory
>       + fake_data

I generally just put something like this into my test_whatever.py

  here = os.path.dirname(__file__)
  fake_data_path = os.path.join(here, 'fake_directory', 'fake_data')

This does not support zipped eggs, but zipped eggs aren't high on my
list of things I think I should support.

> The only way I found to be always able to access them is to use
> "package_data" and
> pkg_resources, which implies that I need to have the egg developed or
> installed on my system.
> Now isn't it normal practice to ignore the tests when installing eggs?

Many packages install tests together with the rest of the package.  If
you search the list archives, you'll find discussions about this

Marius Gedminas
If the facts don't fit the theory, change the facts.
                -- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20111218/11c82037/attachment.pgp>

More information about the testing-in-python mailing list