Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

cricri - Generate test scenarios using unittest

https://badge.fury.io/py/cricri.svg https://api.travis-ci.org/Maillol/cricri.svg?branch=master Documentation Status

Determine and write all possible test scenarios of finite state machines is a hard task. cricri generates test scenarios from state specification.

What are cricri prerequisites ?

python 3.4 or newer

How to install

$ pip install cricri

Example:

An example to test a state machine.

HTTPie compared to cURL

A is a initial state, call m1 shifts the state from A to B and call m2 shifts the state from A to C

We define each state using TestState subclass:

# Define a base class for scenario step.
class State(TestState):
    pass


class StateA(State, start=True): # start=True because A is initial state.
    def input(self):
        # code to go to initial state 'A'
        type(self).machine = Machine()

    def test_a(self):
        # You can use unittest assert methods.
        ...

class StateB(State, previous=['StateA']): # previous=['StateA'] because we can go to this state from 'A'
    def input(self):
        # code to go to 'B' state from 'A'
        type(self).machine.m1()

    def test_b(self):
        # You can use unittest assert methods.
        ...

# previous=['StateA', 'StateB'] because we can go to this state from 'A' or 'B'.
class StateC(State, previous=['StateA', 'StateB']):

    @previous(['StateA'])
    def input(self):
        # Code to go to 'C' state from 'A'
        type(self).machine.m2()

    @previous(['StateB'])
    def input(self):
        # Code to go to 'C' state from 'B'
        type(self).machine.m1()

    def test_c(self):
        # You can use unittest assert methods.
        ...


# You must to use this statment at the end of module to generate **load_tests** function::
load_tests = State.get_load_tests()

Call python3 -m unittest <test_module_name> to launch test.

This exemple generate two scenarios:

machine = Machine()
test_a()
machine.m1()
test_b()
machine.m1()
test_c()

and:

machine = Machine()
test_a()
machine.m2()
test_c()

For more example, see demo directory

Documentation:

Documentation is online at http://cricri.readthedocs.io

Metadata

Release files for cricri 1.0b4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cricri 1.0b4
File Size Uploaded Provenance Actions
cricri-1.0b4.tar.gz 8.1 kB Without provenance Details for cricri-1.0b4.tar.gz

Release files / cricri-1.0b4.tar.gz

Download URL cricri-1.0b4.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
20e481174657f5632bf17faf774b1be161db3e26d00a5de4a500155ca3aa0771
BLAKE2b-256 checksum
How to use checksums
0c3442c212968ec3bab060b4774aa66fa060bce37d339fbc70c3697bacaa9893
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for cricri 1.0b4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page