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.1.25.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.1.25-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pitono-0.1.25.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.1.25.tar.gz
Algorithm Hash digest
SHA256 37cf4718df1e0603c88df69e1831e052b98df57ee43b8acc927c2d2346d0bce9
MD5 a28767e11d562e86846cba61e39787ed
BLAKE2b-256 d9bba909e706de51c6cc2399f160b68489b72ab9efd2cdb140fad3acf47dead5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pitono-0.1.25-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.1.25-py3-none-any.whl
Algorithm Hash digest
SHA256 93871cc3524018b39208327e132f74f38e1de0f1e32482159a83d646c6887a94
MD5 897332133640bf77504fdc13016db87e
BLAKE2b-256 aafd7bb18db763d2b5ddee8c491435019bddb74c5a46400c754d4fba38d4e638

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