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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pitono-0.1.26.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.26.tar.gz
Algorithm Hash digest
SHA256 0032c4db0882f4bee507eda3657bf59b5907854053ede9ed5fe7499a83c66aa3
MD5 18fc543be24a22dd19ca2a80ed623af3
BLAKE2b-256 b1e3b0a1a7816a958df3b9546af3ba39a927caa5b553ad1dfa38cefe46b41f07

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pitono-0.1.26-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.26-py3-none-any.whl
Algorithm Hash digest
SHA256 15aba93bfe6ba5b5d863a40e589d292cce291b8f62e5c41208c6b2e1b1b78b81
MD5 c90a3806d89860803641e2e89f6fe083
BLAKE2b-256 adb32cc1fc405fe2e8be1439f7ac79e5371c7a35be264ce267d69b98c407a291

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