Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basedir not being added to sys.path for doctests #54

Closed
pytestbot opened this issue Jun 22, 2011 · 4 comments
Closed

basedir not being added to sys.path for doctests #54

pytestbot opened this issue Jun 22, 2011 · 4 comments
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Leonardo Santagada (BitBucket: santagada, GitHub: santagada)


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

- projname  
  - module
    - __init__.py
    - ...
  - 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 init.py in tests it still doesn't add the basedir in sys.path.


@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


you need to do something like "python setup.py develop" to make your module importable and then run py.test.

@pytestbot
Copy link
Contributor Author

Original comment by Leonardo Santagada (BitBucket: santagada, GitHub: santagada):


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 init.py should make it add the parent dir to sys.path anyway and then it should work indepently from the cwd.

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


The general strategy is to require "python setup.py 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.

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


Issue #55 was marked as a duplicate of this issue.

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant