davidjrice / autopytest

autopytest observes file system events and runs the appropriate tests

Home Page:https://github.com/davidjrice/autopytest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

autopytest

PyPI version Python versions Build Status Maintainability Codacy Badge Test Coverage

An implementation of autotest for Python inspired by autotest and guard.

autopytest observes file change events and whenever you save a file it runs the appropriate tests with pytest.

Features

autopytest observes file modified events and will perform the following:

  • source files
    • will find and run the associated individual test file
    • upon success, will run the entire suite
    • if we can't find a matching test, run the entire suite
  • test files
    • will run that test file
    • upon success, will run the entire suite

Install

# pip
pip install autopytest

# poetry
poetry add autopytest

Configuration

In your pyproject.toml add the following.

[tool.autopytest]
source_directories = ["app"]
test_directory = "tests"

Usage

cd {project}
autopytest

autopytest {path}

Project Structure

  • Test naming is currently important.
  • Multiple nested directory structures are supported as long as the convention is followed.

Applications

pyproject.toml for applications

[tool.autopytest]
source_directories = ["app", "lib"]
test_directory = "tests"

Given the above configuration. You should use a directory structure like the following. e.g. If app/package/module.py is edited we will attempt to locate and run tests/app/package/test_module.py

πŸ“ app
    πŸ“„ __init__.py
    πŸ“ package
        πŸ“„ __init__.py
        πŸ“„ module.py
πŸ“ lib
πŸ“ tests
    πŸ“„ __init__.py
    πŸ“ app
        πŸ“ package
            πŸ“„ test_module.py
    πŸ“ lib

Libraries

pyproject.toml for libraries

[tool.autopytest]
include_source_dir_in_test_path = false
source_directories = ["src"]
test_directory = "tests"

If you are developing library and want your folder structure like the following. e.g. If src/package/module.py is edited we will attempt to locate and run tests/package/test_module.py

πŸ“ src
    πŸ“ package
        πŸ“„ __init__.py
        πŸ“„ module.py
πŸ“ tests
    πŸ“ package
        πŸ“„ test_module.py

About

autopytest observes file system events and runs the appropriate tests

https://github.com/davidjrice/autopytest

License:MIT License


Languages

Language:Python 83.2%Language:Shell 15.2%Language:Makefile 1.6%