title: Using pytest where test in subfolder
body: <p>I'm using python pytest to run my unit tests.
  My project folders are:</p>
  
  <p><code>Main</code> - contains data file: A.txt</p>
  
  <p><code>Main\Tests</code> - the folder from which I run pytest</p>
  
  <p><code>Main\Tests\A_test</code> - folder that contains a test file</p>
  
  <p>The test in A_test folder uses the file <code>A.txt</code> (that is in Main folder).</p>
  
  <p>My problem is that when I run py.test the test fails because it can't find <code>A.txt</code>.</p>
  
  <p>I found out that it is because pytest uses the path <code>Main\Test</code> when running the test instead of changing the path to <code>Main\Tests\A_test</code> (I'm using relative path when opening <code>A.txt</code> inside the test file)</p>
  
  <p>My question: is there a way to make pytest change directory to the folder of the test it executes for each test? so that relative paths inside the tests will still work? </p>
  
  <p>Is there some other generic way to solve it? (I don't want to change everything to absolute paths or something like this, also this is an example, in real life I have several hundreds tests).</p>
  
  <p>Thank you,</p>
  
  <p>Noam</p>