Code Monkey home page Code Monkey logo

entest's Introduction

Entest

God is testing you

Most of the testing frameworks are pretty old and all of them (python or otherwise) treat unit tests as first class citizens. The ideas of this lib are based on the Testing Trophy. This means that we consider integration tests to be more important. This lib provides a convenient way to explicitly define dependency relationships between tests. Improves transparency of globally needed assets (think fixtures but better).

For how that would look like practically see tests/example.py. This code is referred to in my PyCon talk. https://www.ganjing.com/video/1fic7807r1p1YVbLCkn4uytkJ1c11c

Demo

asciicast

Installing

pip install entest[all]

Documentation

See tests/example.py.

To have a test implicitly depend on all other tests use run_last flag. This is the case for teardown of critical resources for example users. To skip these tests use --skip-teardown or set ENTEST_SKIP_TEARDOWN environment variable.

To have all tests implicitly depend on a given test place it closer to the root of the graph. Use setup_setup to take advantage of depends_on default behavior. (i.e. for the first decorated function in a module TEST_ROOT is taken do be the previous test)

To have a test depend on another test NOT being run use without flag. This is usefull for testing error flows.

Contributing

Please do not maintain a fork! Make a pull request and if it is not obviously bad I will merge it in a timely manner.

python3 -m venv .venv
. .venv/bin/activate
pip install poetry
poetry install
echo "
export PYTHONPATH=$PWD
alias entest="python3 ./entest/cli.py"
" >> .venv/bin/activate
export PYTHONPATH=$PWD
alias entest="python3 ./entest/cli.py"

I would like to change a lot of things structure-wise, but API will stay the same. In particular:

  • depends_on decorator with kwargs previous, run_last and without.
  • STATUS classificator. I see how it can be misused easily, but I will still ship this footgun.

Run tests

entest --graph
entest
entest --skip-teardown
entest --env env_name tests/example.py --snoop

Roadmap

  • Better error output with stackprinter.
  • Verbose mode that automatically applies pySnooper or cyberbrain.
  • An init command that sets up the tests folder with env subfolder.

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.