CircleCI-Public / python-orb

Common CircleCI tasks for the Python programming language.
https://circleci.com/developer/orbs/orb/circleci/python
MIT License
13 stars 37 forks source link

pytest PYTHONPATH to include CIRCLE_WORKING_DIRECTORY #60

Closed tjian closed 3 years ago

tjian commented 3 years ago

Orb version:

1.2.1

What happened:

steps:
    - run:
        command: |
            export PYTHONPATH=$PWD:$PYTHONPATH
            python -m unittest
        name: Run tests with global python env
        working_directory: <<parameters.app-dir>>

When I passed in app-dir, PYTHONPATH should include app-dir

i.e.

export PYTHONPATH=$CIRCLE_WORKING_DIRECTORY:$PWD:$PYTHONPATH

My work-around is to setup to export PYTHONPATH:

      - python/test:
          setup:
            - run:
                name: "set up PYTHONPATH"
                command: echo 'export PYTHONPATH="/home/circleci/project/foo"' >> $BASH_ENV
          args: '--dev'
          pkg-manager: pipenv
          test-tool: pytest
          version: '3.7'
          app-dir: '~/project/foo'

Expected behavior:

It should run the test suite and shouldn't error out with ModuleNotFoundError:

Additional Information:

dsayling commented 3 years ago

Agree with you @tjian, but this is a dupe of #57 - feel free to submit a PR until we get a chance to get around to it.