title: How do you properly integrate unit tests for file parsing with pytest?
body: <p>I'm trying to test file parsing with pytest. I have a directory tree that looks something like this for my project:</p>
  
  <pre><code>project
      project/
          cool_code.py
      setup.py
      setup.cfg
      test/
          test_read_files.py
          test_files/
              data_file1.txt
              data_file2.txt
  </code></pre>
  
  <p>My setup.py file looks something like this:</p>
  
  <pre><code>from setuptools import setup
  
  setup(
      name           = 'project',
      description    = 'The coolest project ever!',
      setup_requires = ['pytest-runner'],
      tests_require  = ['pytest'],
      )
  </code></pre>
  
  <p>My setup.cfg file looks something like this:</p>
  
  <pre><code>[aliases]
  test=pytest
  </code></pre>
  
  <p>I've written several unit tests with pytest to verify that files are properly read. They work fine when I run pytest from within the "<em>test</em>" directory. However, if I execute any of the following from my project directory, the tests fail because they cannot find data files in test_files:</p>
  
  <pre><code>&gt;&gt; py.test
  &gt;&gt; python setup.py pytest
  </code></pre>
  
  <p>The test seems to be sensitive to the directory from which pytest is executed.</p>
  
  <p>How can I get pytest unit tests to discover the files in "data_files" for parsing when I call it from either the test directory or the project root directory?</p>