Skip to main content

Python implementation of Testeranto

Project description

Pitono

The python implementation of testeranto.

Setup

  1. Create a virtual environment:
python3 -m venv venv
  1. Activate the virtual environment:
source venv/bin/activate
  1. Install the package in development mode:
pip install -e .

Running Tests

Make sure the virtual environment is activated, then run your Python tests normally.

Flavored (Pythonic) Version

Pitono now includes a Pythonic, decorator-based syntax for writing tests:

from pitono.flavored import suite, given, when, then

@suite("Calculator Tests")
class CalculatorTests:
    @given("a new calculator")
    def setup_calculator(self):
        return Calculator()
    
    @when("adding {x} and {y}")
    def add_numbers(self, calculator, x, y):
        return calculator.add(x, y)
    
    @then("result should be {expected}")
    def verify_result(self, calculator, expected):
        assert calculator.get_result() == expected
        return calculator

# Run tests
tests = CalculatorTests()
instance = tests.run_tests()

Features:

  1. Decorator-based syntax: Use @suite, @given, @when, @then decorators
  2. String interpolation: Use {parameter} placeholders in descriptions
  3. Automatic conversion: Flavored tests are automatically converted to baseline format
  4. unittest integration: Use PitonoTestCase for integration with Python's unittest framework
  5. Backward compatibility: Works alongside existing baseline tests

Integration with unittest:

import unittest
from pitono.flavored import PitonoTestCase

class TestCalculator(PitonoTestCase):
    @given("a new calculator")
    def setup_calculator(self):
        return Calculator()
    
    # ... test methods

if __name__ == "__main__":
    unittest.main()

Examples

See examples/flavored_example.py for a complete working example.

Documentation

For more details, see:

  • src/lib/pitono/tickets/pythonic.md - Design document for the flavored version
  • src/lib/pitono/src/flavored.py - Implementation of the flavored version

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

pitono-0.2.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

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

pitono-0.2.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file pitono-0.2.0.tar.gz.

File metadata

  • Download URL: pitono-0.2.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for pitono-0.2.0.tar.gz
Algorithm Hash digest
SHA256 70acd380e7b6cd80633a8d2d33b8aec9d3d3cbfde96b3aca6587b7c62950eceb
MD5 babfa9f075ce48b82940ba08d762d74e
BLAKE2b-256 7a6999a6ce6ae4d0049df801ac90d2a17033588e1c8fd1c51924cb863df75678

See more details on using hashes here.

File details

Details for the file pitono-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pitono-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for pitono-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91571e93c30fadd97684d6574a39520ad977407db7ae1f42c1ed28eace6fc503
MD5 0fb469c24cea58857cdf500443271cd5
BLAKE2b-256 88a9596a724e7009c54fb5c3750144bb4194a4a6253bf0a09234d7331e1d8803

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