Skip to content
forked from djarecka/pycontest

Forked to explore the hands-on exercises from the PyCon 2019 workshop. Watched the presentation and worked through the examples as a sandbox to gain practical experience and fill in some testing-related knowledge gaps.

Notifications You must be signed in to change notification settings

sruud/pycontest

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pycontest

A collection of exercises for Pycon 2019 tutorial To trust or to test?: Automated testing of scientific projects with pytest

  • You can find slides from the presentation here
  • You can find full video from the PyCon 2019 conference here

Dependencies:

Tutorial requires Python 3.6, Matplotlib 3.0, Scipy, Numpy, Pytest and Hypothesis. To create example animations you may need ffmpeg or mencoder packages.

How I set up my environments (2025)

This project now targets Python 3.9+. The dependencies have been consolidated into a single requirements.txt file for simplicity.

Python

1. Install ffmpeg and optionally Allure for checking out reports

macOS

Homebrew

brew install ffmpeg
# Allure - optional (shown on github pages)
brew install allure

Windows

Chocolatey Scoop

choco install ffmpeg
# Allure - optional (shown on github pages)
scoop install allure

2. Create and activate a virtual environment

macOS

python3 -m venv venv
source venv/bin/activate

Windows

python -m venv venv
.\venv\Scripts\activate.ps1
  • You should see (venv) in your terminal, indicating you are in the virtual environment.

3. Install Python dependencies

pip install -r requirements.txt

4. Try running the tests (before solving)

  • With pytest.ini now specifying the test path, you can simply run:
pytest

This will discover and run the tests automatically.

If you want more detailed output or need to see print/debug statements, you can use:

pytest -v -s
  • -v: verbose mode -- shows each test's name and status

  • -s: disables output capture =-- useful if you're using print() or pdb

  • You can still specify the test path as an argument pytest tests/allure/

5. Work through the problems alongside the presentation

6. Run Tests -> output results (Allure Reports)

macOS

pytest tests/ --alluredir allure-results

Windows

pytest .\tests\ --alluredir allure-results

7. Generate a report for viewing

Generate a report

  • You can also generate a visual report of this baseline using Allure
allure serve allure-results

💡 Key Takeaways

Troubleshooting:

  • to install the tutorial example code:

    $ pip install .
    
  • to run the tutorial example code without installation:

    $ python -m pycontest.simulation
    
  • in case you have more than one python distribution you may need to specify python version to pytest:

    $ python3 -m pytest tests                      
    

About

Forked to explore the hands-on exercises from the PyCon 2019 workshop. Watched the presentation and worked through the examples as a sandbox to gain practical experience and fill in some testing-related knowledge gaps.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%