Skip to content

Commit b37e189

Browse files
committed
Allow relative imports in tests/timeseries
This also made pylint to look (more?) into the tests in tests/timeseries so this commit also add some fixes to issues reported by pylint after adding the tests/timeseries/__init__.py file. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 4e191e2 commit b37e189

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

tests/timeseries/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# License: MIT
2+
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Timeseries tests."""

tests/timeseries/test_formula_engine.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
"""Tests for the FormulaEngine and the Tokenizer."""
55

6+
import asyncio
67
from datetime import datetime
78
from typing import Dict, List, Optional, Tuple
89

@@ -62,6 +63,7 @@ async def run_test(
6263
io_pairs: List[Tuple[List[Optional[float]], Optional[float]]],
6364
nones_are_zeros: bool = False,
6465
) -> None:
66+
"""Run a formula test."""
6567
channels: Dict[str, Broadcast[Sample]] = {}
6668
builder = FormulaBuilder()
6769
for token in Tokenizer(formula):
@@ -77,17 +79,21 @@ async def run_test(
7779
builder.push_oper(token.value)
7880
engine = builder.build()
7981

80-
assert repr(engine._steps) == postfix
82+
assert repr(engine._steps) == postfix # pylint: disable=protected-access
8183

8284
now = datetime.now()
8385
tests_passed = 0
8486
for io_pair in io_pairs:
85-
input, output = io_pair
86-
[
87-
await chan.new_sender().send(Sample(now, value))
88-
for chan, value in zip(channels.values(), input)
89-
]
90-
assert (await engine.apply()).value == output
87+
io_input, io_output = io_pair
88+
assert all(
89+
await asyncio.gather(
90+
*[
91+
chan.new_sender().send(Sample(now, value))
92+
for chan, value in zip(channels.values(), io_input)
93+
]
94+
)
95+
)
96+
assert (await engine.apply()).value == io_output
9197
tests_passed += 1
9298
assert tests_passed == len(io_pairs)
9399

0 commit comments

Comments
 (0)