Skip to content

Add srcpaths setting #9114

@okken

Description

@okken

What's the problem this feature will solve?

pytest seems designed to test Python packages.
However, it's getting used to test applications as well.
The main problem with testing applications is telling pytest how to find the code under test.
Specifically, sys.path needs modified to include the directory where the code under test lives.

Describe the solution you'd like

I'd like a srcpaths setting. We already have testpaths.
srcpaths would be a list of directories to add to sys.path.

Any project that isn't an installable package (installable through pip) that wants the source code and test code in different directories needs this.

Alternative Solutions

  • Roll your own solutions
  • Plugins
    • pytest-srcpaths does just this thing.
    • pytest-pythonpaths does more
      • does this
      • also has a site_dirs feature which I still don't understand
      • also (undocumented) adds the current directory to sys.path

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: help wanteddevelopers would like help from experts on this topictopic: collectionrelated to the collection phasetype: enhancementnew feature or API change, should be merged into features branchtype: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions