Giter Site home page Giter Site logo

template-pytest_driven_development's Introduction

template-pytest_driven_development_folder

This project is designed to simplify testing with python and pytest. We provide a simple folder structure template for writing code and testing it. We give a few examples showing how to industrialize and simplify testing functions taking common python objects as inputs and outputs, such as integer, strings, lists, as well as pandas dataframes and series.

The folder provides the following elements that can be customized depending on your needs :

  • main.py : main file at the root of the directory
  • ./package : directory where your functions are located
    • functions.py : file with example functions to use in the main or to be tested
  • ./tests : directory where tests are processed
    • conftest.py : common test file where useful functions are defined and imports are made
    • test_functions.py : file to test the functions available in the functions.py file
    • test_functions.json : file to store scenarios to test. The JSON file is then imported in test_functions.py the @pytest.mark.parametrize decorator is ultimately used to pass the scenarios the each test function.
  • ./tests/json : directory containing files providing inputs and outputs for testing functions with lists as inputs. When used, these files are mentionned in test_functions.json.
  • ./tests/csv : directory containing files providing inputs and outputs for testing functions with pandas dataframe or series as inputs. When used, these files are mentionned in test_functions.json.

Requirements & Setup

Make sure you have Pytest installed. Other regular packages are used such as json, numpy, pandas, ...

pip3 install pytest

How to use the folder

All commands can be run from the root of the directory.

To run the main :

python3 main.py

To run the tests :

pytest -v

template-pytest_driven_development's People

Contributors

guillaume-lesaine avatar

Watchers

James Cloos 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.