Skip to content

Commit 6b3fa9a

Browse files
committed
Fix non-unique pipeline name in tests
Clarify readme. Signed-off-by: Gerd Zellweger <mail@gerdzellweger.com>
1 parent 0c50685 commit 6b3fa9a

File tree

4 files changed

+279
-255
lines changed

4 files changed

+279
-255
lines changed

python/tests/README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ uv run python -m pytest tests/platform/test_shared_pipeline.py::TestPipeline::te
5555
To reduce redundant compilation cycles during testing:
5656

5757
* **Inherit from `SharedTestPipeline`** instead of `unittest.TestCase`.
58-
* **Define DDLs** (e.g., `CREATE TABLE`, `CREATE VIEW`) in the **docstring** of each test method.
58+
* **Define DDLs** (e.g., `CREATE TABLE`, `CREATE VIEW`) using the **@SQL** annotation for each test method.
5959
* All DDLs from all test functions in the class are combined and compiled into a single pipeline.
6060
* If a table or view is already defined in one test, it can be used directly in others without redefinition.
6161
* Ensure that all table and view names are unique within the class.
@@ -64,6 +64,11 @@ To reduce redundant compilation cycles during testing:
6464
* Reset it at the end using `self.reset_runtime_config()`.
6565
* Access the shared pipeline via `self.pipeline`.
6666

67+
If a test ever need to create a pipeline manually, e.g., by using `PipelineBuilder`
68+
directly, make sure to generate a unique pipeline name to avoid any conflicts in CI.
69+
You can use the `unique_pipeline_name` helper function from `feldera.testutils` for this
70+
purpose.
71+
6772
#### Example
6873

6974
```python
@@ -82,7 +87,6 @@ class TestAverage(SharedTestPipeline):
8287
...
8388
```
8489

85-
8690
## Running `runtime_aggtest` Tests
8791

8892
These tests run with a different testing framework. To execute them, use:
@@ -91,3 +95,19 @@ These tests run with a different testing framework. To execute them, use:
9195
cd python
9296
PYTHONPATH=`pwd` ./tests/runtime_aggtest/run.sh
9397
```
98+
99+
## Standard pytests
100+
101+
If a test doesn't fit cleanly into the previous models, you can write it
102+
as an ordinary pytest. Make sure the test is self-contained and does not
103+
interfere with other tests.
104+
105+
You can use the `gen_pipeline_name` decorator to generate a unique pipeline name
106+
for each test run. It will also try to shutdown and clean the state of the pipeline
107+
after the test completed.
108+
109+
```python
110+
@gen_pipeline_name
111+
def test_some_property(pipeline_name):
112+
pass
113+
```

0 commit comments

Comments
 (0)