Issue #54 wontfix

basedir not being added to sys.path for doctests

Leonardo Santagada avatarLeonardo Santagada created an issue

when I run py.test 2.0.3 in a project with this dir tree:

- projname  
  - module
    - ...
  - tests
    -  *.txt

if I run "py.test --doctest-glob='*.txt'" pytest doesn't add projname to sys.path, the error is that the tests can't import module. Even if I put a in tests it still doesn't add the basedir in sys.path.

Comments (4)

  1. Leonardo Santagada
    • changed status to new

    This works fine in nose why not make it work in py.test? I know it depends on the cwd, but anything that help taking out the pain to run doctests seems like a good thing to me. And adding a should make it add the parent dir to sys.path anyway and then it should work indepently from the cwd.

  2. holger krekel

    The general strategy is to require "python develop" or "pip install -e ." when running tests, for the tests to find the code they are supposed to test. Otherwise it becomes hard to run the tests against an installed package which is something where py.test shouldn't get in the way.

  3. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.