title: how to distribute python packages with unittests as executable entry points?
body: <p>I am writing a python package that has executable scripts registered into 'setup.py' as entry points. when the package is installed these are placed
  into the "bin" directory of the python package installation without the ".py" extension. I want to be able to run the unit tests of the package
  as an executable too once the package is installed. the unittests are in "test_package.py" which is in the "entry_points" of setup.py:
  run the python packages</p>
  
  <pre><code>setup(
    entry_points={
        'console_scripts': [
            'my_exec = mypackage.my_exec:main'
            'test_package = mypackage.test_package.main'],
    }
  )
  </code></pre>
  
  <p>the test_package.py script reads some files from "test-files":</p>
  
  <pre><code>mypackage/
    setup.py
    mypackage/
      my_exec.py
      test_package.py
      # files needed to run tests
      test-files/
      # directory containing files written by 'test_package'
      test-results/
  </code></pre>
  
  <p>when I run "test_package.py" <em>inside</em> the package it works fine. however when I install it and "test_package" is created as executable in "bin", then running:</p>
  
  <pre><code>$ test_package
  </code></pre>
  
  <p>from command line cannot find the tests. it says "ran 0 tests". what is wrong with this directory structure? what is the right way to distribute unit tests in a way that
  they can be run from the command line even if they create files?  if the package is installed for someone using sudo privileges then i want the user which is sudo-less to be able to run these without requiring write access to where package is installed.</p>
  
  <p>the structure of test_package.py is:</p>
  
  <pre><code>class TestPackage(unittest.Test):
    def setUp():
       ...
    def test_foo():
       # read stuff from 'test-files/'
       # ...
       # output stuff to 'test-results/'
       # ...
  
  def main():
      unittest.main()
  
  
  if __name__ == '__main__':
      main()
  </code></pre>