Giter VIP home page Giter VIP logo

101_pytest's Introduction

Purpose of this repo

The purpose of this repository is mainly to explore pytest. Tests can be found in tests.

To ensure code quality, this repository leverages the capabilities of pre-commit. If you're curious about pre-commit and want to explore its features further, I recommend checking out this other repository: 101_pre-commit


Table of contents

Content Description
src ETL script, input, and output datasets serving as a foundation for writing focused tests.
tests Tests - Go to tests/README.md for more details on what's covered by this repo.
tests/unit Unit tests
tests/integration Integration tests
github_ci Workflow that runs static analysis, the script, the tests and generates test reports and test coverage report

Running pytest locally

To run locally, you will need Python 3.11 or newer installed in your local environment. Then, just install the dependencies and execute the main.py file:

Create a virtual environment:

python3 -m venv .venv

Activate local environment:

source .venv/bin/activate

Install dependencies:

pip install -r requirements.txt

Install git hooks (optional, do it only if you wanna use pre-commit):

pre-commit install

Run script:

python3 src/main.py

Run tests:

pytest -v tests

Run test coverage command to generate report locally (it will be generated by the GitHub Actions workflow automatically and it will be stored as an artifact. You can look for it there instead of generating it locally, if you prefer.):

pytest --cov --cov-report=html

If you installed git hooks but wanna skip pre-commit checks, run:

git commit -m"message" --no-verify

Finding the Coverage Report generated automatically by Github Actions worklow


Go to the project in Github and click in Actions (top left):

Actions

Select the last workflow run:

Running workflow

Once it's finished, you should be able to see the artifacts it generated (bottom):

Artifacts Storage

Download it, unzip it. To see the Test Coverage Report, click on coverage-report.html and open index.html

Artifact Files

You should see something like this:

Coverage report

To expand and see more details, click in src/main.py:

Coverage report detail

101_pytest's People

Contributors

anneglienke avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.