Skip to main content

Coverage-driven automatic unit test generator for Python projects.

Project description

Pyster

Build Status Code Style Coverage Status PyPI version

Pyster is a coverage-driven automatic unit test generator for Python projects.

Pre-request

Usage

# Stage 1: Init pyster config file
python3 -m pyster.init \
  --project_path <path-to-project> \
  --module_name <module-for-testing> \
  --path_runtime <runtime-analysis-code>
# Stage 2: Generate unit tests
python3 -m pyster.gen \
  --project_path <path-to-project> \
  --module_name <module-for-testing> \
  --user_tests <list-of-existing-test-files> \
  --timeout <timeout-limit> \
  --coverage <coverage-target>

# Run Stage 1 and Stage 2 together:
python3 -m pyster \
  --project_path <path-to-project> \
  --module_name <module-for-testing> \
  --path_runtime <runtime-analysis-code> \
  --user_tests <list-of-existing-test-files> \
  --timeout <timeout-limit> \
  --coverage <coverage-target>

Test

pytest tests

Sample execution

# Phase 1
python3 -m pyster.init --project_path tests/foobar --module_name foobar.foobar
# Phase 2
python3 -m pyster.gen --project_path tests/foobar --module_name foobar.foobar -t 1 -c 80

Pyster Logic

pyster-logic

The graph above is a high-level summary of Pyster's workflow.

Pyster contains two phases:

  • Phase 1: Type Analysis (init stage)
    • Input:
      • project_path: Absolute/relative path to project folder
      • module_name: Name of Python module for generating tests
      • path_runtime(optional): User-written Python file (e.g. existing test files) that makes use of functions in the selected module.
    • Output:
      • module_name.json: A configuration file containing all information used to randomly generate function calls. (All function signatures and their argument types, constructor of user-defined classes, etc.) This file can be further modified by user to provide more detailed type-related information.
  • Phase 2: Test Generation (gen stage)
    • Input:
      • timeout: Pyster terminates after timeout seconds.
      • coverage: Pyster terminates after test cases reach coverage code coverage rate.
      • user_tests(optional): If current module already has test suite, user_tests can be provided as a list of files so that Pyster will not generate tests covering lines already tested.
    • Output:
      • A runnable module_nameTest.py file containing all automatically generated unit tests as well as command-line output of coverage report.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyster-python-0.1.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyster_python-0.1.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file pyster-python-0.1.0.tar.gz.

File metadata

  • Download URL: pyster-python-0.1.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.3

File hashes

Hashes for pyster-python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9755b5d1e296a51250e3e420b2d9bdb2ecbe59dc39edd797b34141e46a792a6f
MD5 1e2c5fd5ba11db08d2ee3c3380f190f8
BLAKE2b-256 11b3b3d6a0ce228d8195d85b12a021aa090fce673a1d11ad820a4d1f4c385c57

See more details on using hashes here.

File details

Details for the file pyster_python-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyster_python-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.3

File hashes

Hashes for pyster_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3874165b1cc7374f2c10fbdefcb916b77e998577865d4f8770d36bd318177a5
MD5 7c6622d5f64a32b253a29d1f5be6f348
BLAKE2b-256 b57eaa9555b361a02b9eb61c4f3695e3f74f32f55f68b22922190fc71685181e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page