Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get PyTest to find my tests in Github?

I have a project layout as follows:

ProjectRoot
    | 
    \---------CoreImplelemntation
    |                |
    |                \--CoreSourceFile1.py
    |                \--Test_CoreSourceFile1.py
    | 
    \---------WebUIThatReferencesCoreImplentation
                     |
                     \--WebSourceFile1.py
                     \--Test_WebSourceFile1.py

Locally I can run (from the root folder of the project) pipenv run pytest and all my tests are discovered in those subdirectories and executed.

When I try to do this in a workflow in github however, all of the following have resulted in no tests being run:

    - name: Test with pytest
      run: |
        pytest
    - name: Test with pytest
      run: |
        pipenv run pytest
    - name: Test with pytest
      run: |
        pipenv run pytest .

Output looks like this each time:

Run pipenv run pytest .
Creating a virtualenv for this project...
Pipfile: /home/runner/work/ed-scout/ed-scout/Pipfile
Using /opt/hostedtoolcache/Python/3.7.8/x64/bin/python3.7m (3.7.8) to create virtualenv...
created virtual environment CPython3.7.8.final.0-64 in 452ms
  creator CPython3Posix(dest=/home/runner/.local/share/virtualenvs/ed-scout-bRIm7jsM, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, wheel=bundle, setuptools=bundle, via=copy, app_data_dir=/home/runner/.local/share/virtualenv)
    added seed packages: pip==20.2.2, setuptools==49.6.0, wheel==0.35.1
  activators PythonActivator,FishActivator,XonshActivator,CShellActivator,PowerShellActivator,BashActivator


Successfully created virtual environment!
Virtualenv location: /home/runner/.local/share/virtualenvs/ed-scout-bRIm7jsM
============================= test session starts ==============================
platform linux -- Python 3.7.8, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
rootdir: /home/runner/work/ed-scout/ed-scout
collected 0 items

============================ no tests ran in 0.03s =============================
##[error]Process completed with exit code 5.

Workflow file is as follows: https://github.com/joncage/ed-scout/pull/18/files

Is there some magic I'm missing to get this running or a way to interrogate what's going wrong here?

like image 524
Jon Cage Avatar asked Oct 25 '25 20:10

Jon Cage


1 Answers

Turns out I'm running my tests locally on a Windows machine whereas the github tests were running under linux. PyTest looks for test... files and I had Test... files so this is a case sensitivity issue; renaming the test files allows PyTest to find them.

like image 145
Jon Cage Avatar answered Oct 27 '25 09:10

Jon Cage



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!