File: testing_debounce.py

package info (click to toggle)
python-rx 4.0.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,056 kB
  • sloc: python: 39,070; javascript: 77; makefile: 24
file content (26 lines) | stat: -rw-r--r-- 672 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from reactivex import operators as ops
from reactivex.testing.marbles import marbles_testing

"""
Tests debounceTime from reactivexjs
https://github.com/ReactiveX/rxjs/blob/master/spec/operators/debounceTime-spec.ts

it should delay all element by the specified time
"""
with marbles_testing(timespan=1.0) as (start, cold, hot, exp):

    e1 = cold("-a--------b------c----|")
    ex = exp("------a--------b------(c,|)")
    expected = ex

    def create():
        return e1.pipe(
            ops.debounce(5),
        )

    results = start(create)
    assert results == expected

print("debounce: results vs expected")
for r, e in zip(results, expected):
    print(r, e)