Skip to content

Commit

Permalink
Adds test for robinhood#674 that fails only on Cython
Browse files Browse the repository at this point in the history
  • Loading branch information
forsberg committed Oct 21, 2020
1 parent 23c7e61 commit 203929d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 4 additions & 2 deletions t/cython/test_cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ class test_Cython:
This test is here to ensure we get a clear indication if e.g. Travis
fails to correctly install Cython and build our modules
"""
@pytest.mark.skipif(not bool(os.environ.get("USE_CYTHON")), reason="Cython not enabled")
@pytest.mark.skipif(bool(os.environ.get('NO_CYTHON', False)), reason="Cython disabled")
@pytest.mark.skipif(not bool(os.environ.get('USE_CYTHON')),
reason='Cython not enabled')
@pytest.mark.skipif(bool(os.environ.get('NO_CYTHON', False)),
reason='Cython disabled')
def test_import(self):
from faust._cython.windows import HoppingWindow
HoppingWindow(60, 60)
Expand Down
17 changes: 17 additions & 0 deletions t/unit/windows/test_hopping_window.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pytest import approx
from faust.windows import HoppingWindow


Expand Down Expand Up @@ -59,3 +60,19 @@ def test_stale_timestamp(self):
for time in range(0, now_timestamp - expires):
print(f'TIME: {time} NOW TIMESTAMP: {now_timestamp}')
assert window.stale(time, now_timestamp) is True

def test_ranges_types(self):
size = 60
step = 60
window = HoppingWindow(size, step)

# There's nothing special about this timestamp,
# it was simply when the test was created
timestamp = 1603122451.544989
window_ranges = window.ranges(timestamp)

assert len(window_ranges) == 1
assert type(window_ranges[0][0]) == float
assert type(window_ranges[0][1]) == float
assert window_ranges[0][0] == approx(1603122420.0)
assert window_ranges[0][1] == approx(1603122479.9)

0 comments on commit 203929d

Please sign in to comment.