title: coverage.py does not cover script if py.test executes it from another directory
body: <p>I got a python script which takes command line arguments, working with some files.
  I'm writing succeeding tests with <code>py.test</code> putting this script through its paces, executing it with <code>subprocess.call</code>.</p>
  
  <p>Now I want to analyze code coverage with <code>coverage.py</code>.
  Coverage, when used via the <code>pytest-cov</code> plugin (which has subprocess-handling built-in), <strong>does not see/cover my script</strong> when it is called from a temporary testing directory created with <code>py.test</code>'s <code>tmpdir</code> fixture.
  Coverage <strong>does see</strong> my script when it's called in the directory it resides in (and the filename argument points to a remote path).</p>
  
  <p>In both situations, my <strong>tests pass</strong>! Coverage 3.6, pytest-2.3.5, pytest-cov 1.6, all from PyPi.</p>
  
  <p>Question: How can I get coverage to recognize my script even if it's executed in another directory? Is this a bug in coverage, or something which is just not possible to do? Would be surprised if the latter, after all, <code>tmpdir</code> is a stock mechanism of py.test...</p>
  
  <p><strong>Minimal example:</strong></p>
  
  <p>I got a script <code>my_script.py</code> which just echoes the contents of a file <code>arg_file.txt</code> supplied via command-line argument. In two different tests, this is once called in a <code>tmpdir</code>, and once in the script's location. Both tests pass, but the in the tmpdir test, I get no coverage information! </p>
  
  <p>Test run:</p>
  
  <pre><code>~/pytest_experiment$ py.test -s
  =================================== test session starts ====================================
  platform linux2 -- Python 2.7.4 -- pytest-2.3.5
  plugins: cov
  collected 2 items 
  
  tests/test_in_scriptdir.py 
  set_up: In directory /tmp/pytest-52/test_10
  Running in directory /home/cbuchner/pytest_experiment
  Command: ./my_script.py /tmp/pytest-52/test_10/arg_file.txt
  --Contents of arg_file.txt--
  
  .
  tests/test_in_tmpdir.py 
  set_up: In directory /tmp/pytest-52/test_11
  Running in directory /tmp/pytest-52/test_11
  Command: /home/cbuchner/pytest_experiment/my_script.py arg_file.txt
  --Contents of arg_file.txt--
  
  .
  
  ================================= 2 passed in 0.06 seconds =================================
  </code></pre>
  
  <p>Coverage: </p>
  
  <pre><code>~/pytest_experiment$ py.test --cov=my_script.py tests/test_in_scriptdir.py=================================== test session starts ====================================
  platform linux2 -- Python 2.7.4 -- pytest-2.3.5
  plugins: cov
  collected 1 items 
  
  tests/test_in_scriptdir.py .
  --------------------- coverage: platform linux2, python 2.7.4-final-0 ----------------------
  Name        Stmts   Miss  Cover
  -------------------------------
  my_script       3      0   100%
  
  ================================= 1 passed in 0.09 seconds =================================
  ~/pytest_experiment$ py.test --cov=my_script.py tests/test_in_tmpdir.py=================================== test session starts ====================================
  platform linux2 -- Python 2.7.4 -- pytest-2.3.5
  plugins: cov
  collected 1 items 
  
  tests/test_in_tmpdir.py .Coverage.py warning: No data was collected.
  
  --------------------- coverage: platform linux2, python 2.7.4-final-0 ----------------------
  Name    Stmts   Miss  Cover
  ---------------------------
  
  ================================= 1 passed in 0.09 seconds =================================
  </code></pre>
  
  <p>The files are here: <a href="https://gist.github.com/bilderbuchi/6412754">https://gist.github.com/bilderbuchi/6412754</a></p>
  
  <p><strong>Edit:</strong> Interstingly, when running the coverage tests with <code>-s</code>, too, there's more curious output - coverage warns that <code>No data was collected</code>, when obviously it was collected, and in the <code>tmpdir</code> test warns that <code>Module my_script.py was never imported.</code>??</p>
  
  <pre><code>~/pytest_experiment$ py.test -s --cov=my_script.py tests/test_in_scriptdir.py
  =================================== test session starts ====================================
  platform linux2 -- Python 2.7.4 -- pytest-2.3.5
  plugins: cov
  collected 1 items 
  
  tests/test_in_scriptdir.py 
  set_up: In directory /tmp/pytest-63/test_10
  Running in directory /home/cbuchner/pytest_experiment
  Command: ./my_script.py /tmp/pytest-63/test_10/arg_file.txt
  --Contents of arg_file.txt--
  
  Coverage.py warning: No data was collected.
  .
  --------------------- coverage: platform linux2, python 2.7.4-final-0 ----------------------
  Name        Stmts   Miss  Cover
  -------------------------------
  my_script       3      0   100%
  
  ================================= 1 passed in 0.09 seconds =================================
  ~/pytest_experiment$ py.test -s --cov=my_script.py tests/test_in_tmpdir.py=================================== test session starts ====================================
  platform linux2 -- Python 2.7.4 -- pytest-2.3.5
  plugins: cov
  collected 1 items 
  
  tests/test_in_tmpdir.py 
  set_up: In directory /tmp/pytest-64/test_10
  Running in directory /tmp/pytest-64/test_10
  Command: /home/cbuchner/pytest_experiment/my_script.py arg_file.txt
  --Contents of arg_file.txt--
  
  Coverage.py warning: Module my_script.py was never imported.
  Coverage.py warning: No data was collected.
  Coverage.py warning: Module my_script.py was never imported.
  Coverage.py warning: No data was collected.
  .Coverage.py warning: No data was collected.
  
  --------------------- coverage: platform linux2, python 2.7.4-final-0 ----------------------
  Name    Stmts   Miss  Cover
  ---------------------------
  
  ================================= 1 passed in 0.09 seconds =================================
  </code></pre>