Automated Testing in Python with pytest, tox, and GitHub Actions

Share
Embed
  • Loading...
  • Published on:  Saturday, September 11, 2021
  • Take your Python project to the next level of professionalism.

    Automated testing in Python is an important way to take your Python project to the next level of dependability and professionalism. There are a lot of steps, but it's not too difficult to setup your tests to run automatically across multiple different operating systems and versions of Python whenever you push a commit or receive a pull request on your repository. We show you the entire process, step by step, to take a plain old project and turn it into an installable package with automated tests that run when you push to GitHub. We use pytest, mypy, and flake8 for testing, type checking, and code linting. Then we use tox to run all of these commands in isolated virtual environments. Finally, we use GitHub actions to run tox on a push or a pull request. Automated testing is the first and most important step in the more general world of continuous integration (CI), and continuous delivery or continuous deployment (CD). In this video we focus on automated testing, not on general CI/CD, as there is already PLENTY of material to cover.

    ― mCoding with James Murphy (https://mcoding.io)

    Source code: https://github.com/mCodingLLC/SlapThatLikeButton-TestingStarterProject
    Other code: https://github.com/mCodingLLC/VideosSampleCode
    pytest docs: https://docs.pytest.org/en/latest/
    mypy docs: https://mypy.readthedocs.io/en/stable/index.html
    flake8 docs: https://flake8.pycqa.org/en/latest/
    setuptools (setup py and setup cfg) docs: https://setuptools.readthedocs.io/en/latest/index.html
    tox docs: https://tox.readthedocs.io/en/latest/
    GitHub Actions docs: https://docs.github.com/en/actions
    tox-gh-actions repo: https://github.com/ymyzk/tox-gh-actions

    SUPPORT ME ⭐
    ---------------------------------------------------
    Patreon: https://patreon.com/mCoding
    Paypal: https://www.paypal.com/donate/?hosted_button_id=VJY5SLZ8BJHEE
    Other donations: https://mcoding.io/donate

    Top patrons and donors: Laura M, Jameson, John Martin, Dragos C, Vahnekie, Pieter G, Sigmanificient, Casey G

    BE ACTIVE IN MY COMMUNITY 😄
    ---------------------------------------------------
    Discord: https://discord.gg/Ye9yJtZQuN
    Github: https://github.com/mCodingLLC/
    Reddit: https://www.reddit.com/r/mCoding/
    Facebook: fb.com/james.mcoding

    CHAPTERS
    ---------------------------------------------------
    0:00 Intro
    1:21 Overview of the video
    2:56 Structuring your project
    8:35 Pytest, mypy, flake8
    10:58 Pytest features
    18:34 Test multiple envs with tox
    21:18 Test on commit with GH Actions
    25:22 Readme badge
    26:34 Thanks
  • Source: https://youtu.be/DhUpxWjOhME
Loading...

Comment