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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pitono-0.1.27.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.27.tar.gz
Algorithm Hash digest
SHA256 0d242a890d52c3324c7a7a4f2f30695c41bf2f871c29af6d763a307b29202932
MD5 ad715c5cfe63336ed140e9dfd23d1b70
BLAKE2b-256 64ec352ceb153454ac89b4b21fe637016d65ec3acc2be9c39bf77abbf898df22

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pitono-0.1.27-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.27-py3-none-any.whl
Algorithm Hash digest
SHA256 ec688c97a38faae4cdf102088e49c1e2891d2d9f8521dc7b0919022831519188
MD5 be7e20befbc3513323823413eb99e9f9
BLAKE2b-256 9a2ef47cd5d10953b0f751047a491e78f7a931a389485be1c1e5f39364cfae82

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