Skip to main content

Pytest Streaming

Augmenting and simplifying the flow of testing streaming applications including pulsar, google pubsub, kafka, and nats.

semantic-release: python PyPI - Downloads Tests Formatting Typing Docs License

Python Pytest Apache Google Cloud

Documentation

PyTest streaming documentation can be found here.

Description

This PyTest plugin makes it easy to test streaming functionality (unit, integration, test, etc) through seamless and easy to use decorators. The plugin currently supports bootstrapping of resources for the following technologies

  1. Apache Pulsar
  2. Google PubSub
  3. [Coming soon] Kafka
  4. [Coming soon] Nats
  5. [Coming soon] Kinesis

The only setup the user needs to take is to have these running locally (ideally via Docker). Docker compose files are provided for each of these, with formal documentation on how to setup everything easily in CI/CD as well.

 

Quick start

To get started, you should reference the extensive documentation page found here.

For a quick start, you can follow these steps

Install pytest-streaming

pip install pytest-streaming

 

Utilize the decorator for the streaming technology of your choice

If you're using docker compose, adding this for pulsar will get you up and running end to end (docker-compose.yml)

services:
  pulsar:
    image: apachepulsar/pulsar:latest
    container_name: pulsar
    ports: ['6650:6650', '8080:8080']
    environment:
    - PULSAR_STANDALONE_ENABLED=true
    - allowAutoTopicCreation=true
    command: [bin/pulsar, standalone]

Now you can run: docker compose up -d to have pulsar locally bootstrapped.

Lastly, you can simply create test specific topics

class TestPulsarProducer:
    @pytest.mark.pulsar(topics=["test-topic1", "test-topic2"])
    def test_pubsub_marker_topic_creation_base(self) -> None:
        # these pulsar topics are now available and completely clean
        ...

Everything will be created and cleaned up for you by default on every test run. Each decorator has a suite of customizable features. Read the documentation to see other parameters you can use and how you can create topics for global use (integration tests).

 

Adding to your CI/CD

Running this in CI/CD is as simple and ensuring pulsar (or other streaming choice) is running in the network. For the example above, adding this step to your GitHub action will yield all the setup required

- name: run docker-compose
    run: |
    docker compose up -d
    sleep 5s

 

Examples

A suite of examples which are provided and ran within the test suite directly to verify functionality. These can be found under the examples directory at the root level of this project.

Release files for pytest-streaming 1.3.0

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

Source distribution (sdist)

Source distribution for pytest-streaming 1.3.0
File Size Uploaded
pytest_streaming-1.3.0.tar.gz 15.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-streaming 1.3.0
File Interpreter ABI Platform
pytest_streaming-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 39.3 kB

Release files / pytest_streaming-1.3.0.tar.gz

Download URL pytest_streaming-1.3.0.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
05e6d6fbbe858cc41f010224575c5ddd2268926af39b6de1a2265bee911cd6a9
BLAKE2b-256 checksum
How to use checksums
07a194be84de3a78247f508987311c2e5d4df7e9c2feadf792f299ba54447609
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / pytest_streaming-1.3.0-py3-none-any.whl

Download URL pytest_streaming-1.3.0-py3-none-any.whl
Size 23.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65c52347b59b0ed020835325c8e4e843c992ff4f86ee577e47d6deed9433c840
BLAKE2b-256 checksum
How to use checksums
41d613b91734425d6bad38f2acb2840a56ea0b2ac87dac380ae52dd4dd67d3d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

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