Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/test_observable/test_bufferwithcount.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from typing import NoReturn

from reactivex import operators as ops
from reactivex.testing import ReactiveTest, TestScheduler
Expand All @@ -17,7 +18,7 @@ class RxException(Exception):


# Helper function for raising exceptions within lambdas
def _raise(ex):
def _raise(ex: Exception) -> NoReturn:
raise RxException(ex)


Expand Down
26 changes: 14 additions & 12 deletions tests/test_observable/test_create.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import unittest
from typing import NoReturn

import reactivex
from reactivex.disposable import Disposable
from reactivex.testing import ReactiveTest, TestScheduler

on_next = ReactiveTest.on_next
Expand All @@ -17,7 +19,7 @@ class RxException(Exception):


# Helper function for raising exceptions within lambdas
def _raise(ex):
def _raise(ex: str) -> NoReturn:
raise RxException(ex)


Expand All @@ -29,7 +31,7 @@ def _create():
def subscribe(o, scheduler=None):
o.on_next(1)
o.on_next(2)
return lambda: None
return Disposable()

return reactivex.create(subscribe)

Expand All @@ -43,9 +45,9 @@ def _create():
def subscribe(o, scheduler=None):
o.on_completed()
o.on_next(100)
o.on_error("ex")
o.on_error(Exception("ex"))
o.on_completed()
return lambda: None
return Disposable()

return reactivex.create(subscribe)

Expand All @@ -58,11 +60,11 @@ def test_create_error(self):

def _create():
def subscribe(o, scheduler=None):
o.on_error(ex)
o.on_error(Exception(ex))
o.on_next(100)
o.on_error("foo")
o.on_error(Exception("foo"))
o.on_completed()
return lambda: None
return Disposable()

return reactivex.create(subscribe)

Expand Down Expand Up @@ -109,7 +111,7 @@ def action4(scheduler, state):
def dispose():
is_stopped[0] = True

return dispose
return Disposable(dispose)

return reactivex.create(subscribe)

Expand All @@ -124,21 +126,21 @@ def dispose():
def test_create_observer_throws(self):
def subscribe(o, scheduler=None):
o.on_next(1)
return lambda: None
return Disposable()

with self.assertRaises(RxException):
reactivex.create(subscribe).subscribe(lambda x: _raise("ex"))

def subscribe2(o, scheduler=None):
o.on_error("exception")
return lambda: None
o.on_error(Exception("exception"))
return Disposable()

with self.assertRaises(RxException):
reactivex.create(subscribe2).subscribe(on_error=lambda ex: _raise("ex"))

def subscribe3(o, scheduler=None):
o.on_completed()
return lambda: None
return Disposable()

with self.assertRaises(RxException):
reactivex.create(subscribe3).subscribe(on_completed=lambda: _raise("ex"))
3 changes: 2 additions & 1 deletion tests/test_observable/test_debounce.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from typing import NoReturn

from reactivex import empty, never, throw
from reactivex import operators as _
Expand All @@ -18,7 +19,7 @@ class RxException(Exception):


# Helper function for raising exceptions within lambdas
def _raise(ex):
def _raise(ex: Exception) -> NoReturn:
raise RxException(ex)


Expand Down
3 changes: 2 additions & 1 deletion tests/test_observable/test_defer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from typing import NoReturn

import reactivex
from reactivex.testing import ReactiveTest, TestScheduler
Expand All @@ -18,7 +19,7 @@ class RxException(Exception):


# Helper function for raising exceptions within lambdas
def _raise(ex):
def _raise(ex: Exception) -> NoReturn:
raise RxException(ex)


Expand Down
3 changes: 2 additions & 1 deletion tests/test_observable/test_delay.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import unittest
from datetime import datetime, timezone
from typing import NoReturn

from reactivex.operators import delay
from reactivex.testing import ReactiveTest, TestScheduler
Expand All @@ -23,7 +24,7 @@ class RxException(Exception):


# Helper function for raising exceptions within lambdas
def _raise(ex):
def _raise(ex: Exception) -> NoReturn:
raise RxException(ex)


Expand Down
3 changes: 2 additions & 1 deletion tests/test_observable/test_delaywithmapper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from typing import NoReturn

from reactivex import Observable, abc
from reactivex import operators as ops
Expand All @@ -20,7 +21,7 @@ class RxException(Exception):


# Helper function for raising exceptions within lambdas
def _raise(ex):
def _raise(ex: Exception) -> NoReturn:
raise RxException(ex)


Expand Down
3 changes: 2 additions & 1 deletion tests/test_observable/test_distinct.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import math
import unittest
from typing import NoReturn

from reactivex import operators as ops
from reactivex.testing import ReactiveTest, TestScheduler
Expand All @@ -18,7 +19,7 @@ class RxException(Exception):


# Helper function for raising exceptions within lambdas
def _raise(ex):
def _raise(ex: Exception) -> NoReturn:
raise RxException(ex)


Expand Down
7 changes: 4 additions & 3 deletions tests/test_observable/test_distinctuntilchanged.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from typing import NoReturn

import reactivex
from reactivex import operators as ops
Expand All @@ -18,7 +19,7 @@ class RxException(Exception):


# Helper function for raising exceptions within lambdas
def _raise(ex):
def _raise(ex: Exception) -> NoReturn:
raise RxException(ex)


Expand Down Expand Up @@ -282,7 +283,7 @@ def test_distinct_until_changed_key_mapper_throws(self):
)

def create():
return xs.pipe(ops.distinct_until_changed(lambda x: _raise(ex)))
return xs.pipe(ops.distinct_until_changed(lambda x: _raise(Exception(ex))))

results = scheduler.start(create)
assert results.messages == [on_error(210, ex)]
Expand All @@ -296,7 +297,7 @@ def test_distinct_until_changed_comparer_throws(self):

def create():
return xs.pipe(
ops.distinct_until_changed(comparer=lambda x, y: _raise(ex)),
ops.distinct_until_changed(comparer=lambda x, y: _raise(Exception(ex))),
)

results = scheduler.start(create)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_observable/test_expand.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from typing import NoReturn

from reactivex import operators as ops
from reactivex.testing import ReactiveTest, TestScheduler
Expand All @@ -17,7 +18,7 @@ class RxException(Exception):


# Helper function for raising exceptions within lambdas
def _raise(ex):
def _raise(ex: Exception) -> NoReturn:
raise RxException(ex)


Expand Down
4 changes: 0 additions & 4 deletions tests/test_observable/test_finally.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def test_finally_only_called_once_empty(self):

def action():
invasserte_count[0] += 1
return invasserte_count

some_observable = reactivex.empty().pipe(ops.finally_action(action))

Expand All @@ -36,7 +35,6 @@ def test_finally_empty(self):
def create():
def action():
invasserted[0] = True
return invasserted[0]

return xs.pipe(ops.finally_action(action))

Expand All @@ -55,7 +53,6 @@ def test_finally_return(self):
def create():
def action():
invasserted[0] = True
return invasserted[0]

return xs.pipe(ops.finally_action(action))

Expand All @@ -78,7 +75,6 @@ def test_finally_on_error(self):
def create():
def action():
invasserted[0] = True
return invasserted[0]

return xs.pipe(ops.finally_action(action))

Expand Down
3 changes: 2 additions & 1 deletion tests/test_observable/test_firstordefault.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from typing import NoReturn

from reactivex import operators as ops
from reactivex.testing import ReactiveTest, TestScheduler
Expand All @@ -17,7 +18,7 @@ class RxException(Exception):


# Helper function for raising exceptions within lambdas
def _raise(ex):
def _raise(ex: Exception) -> NoReturn:
raise RxException(ex)


Expand Down
3 changes: 2 additions & 1 deletion tests/test_observable/test_fromcallback.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from typing import NoReturn

import reactivex
from reactivex.testing import ReactiveTest
Expand All @@ -17,7 +18,7 @@ class RxException(Exception):


# Helper function for raising exceptions within lambdas
def _raise(ex):
def _raise(ex: Exception) -> NoReturn:
raise RxException(ex)


Expand Down
7 changes: 5 additions & 2 deletions tests/test_observable/test_fromiterable.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from typing import NoReturn

import reactivex
from reactivex.testing import ReactiveTest, TestScheduler
Expand All @@ -17,7 +18,7 @@ class RxException(Exception):


# Helper function for raising exceptions within lambdas
def _raise(ex):
def _raise(ex: Exception) -> NoReturn:
raise RxException(ex)


Expand Down Expand Up @@ -71,4 +72,6 @@ def test_double_subscribe_to_iterable(self):

def test_observer_throws(self):
with self.assertRaises(RxException):
reactivex.from_iterable([1, 2, 3]).subscribe(lambda x: _raise("ex"))
reactivex.from_iterable([1, 2, 3]).subscribe(
lambda x: _raise(Exception("ex"))
)
15 changes: 8 additions & 7 deletions tests/test_observable/test_generatewithrelativetime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from typing import NoReturn

import reactivex
from reactivex.testing import ReactiveTest, TestScheduler
Expand All @@ -17,7 +18,7 @@ class RxException(Exception):


# Helper function for raising exceptions within lambdas
def _raise(ex):
def _raise(ex: Exception) -> NoReturn:
raise RxException(ex)


Expand Down Expand Up @@ -45,7 +46,7 @@ def test_generate_timespan_throw_condition(self):

def create():
return reactivex.generate_with_relative_time(
0, lambda x: _raise(ex), lambda x: x + 1, lambda x: x + 1
0, lambda x: _raise(Exception(ex)), lambda x: x + 1, lambda x: x + 1
)

results = scheduler.start(create)
Expand All @@ -57,7 +58,7 @@ def test_generate_timespan_throw_iterate(self):

def create():
return reactivex.generate_with_relative_time(
0, lambda x: True, lambda x: _raise(ex), lambda x: x + 1
0, lambda x: True, lambda x: _raise(Exception(ex)), lambda x: x + 1
)

results = scheduler.start(create)
Expand All @@ -69,7 +70,7 @@ def test_generate_timespan_throw_timemapper(self):

def create():
return reactivex.generate_with_relative_time(
0, lambda x: True, lambda x: x + 1, lambda x: _raise(ex)
0, lambda x: True, lambda x: x + 1, lambda x: _raise(Exception(ex))
)

results = scheduler.start(create)
Expand Down Expand Up @@ -109,7 +110,7 @@ def test_generate_datetime_offset_throw_condition(self):

def create():
return reactivex.generate_with_relative_time(
0, lambda x: _raise(ex), lambda x: x + 1, lambda x: x + 1
0, lambda x: _raise(Exception(ex)), lambda x: x + 1, lambda x: x + 1
)

results = scheduler.start(create)
Expand All @@ -121,7 +122,7 @@ def test_generate_datetime_offset_throw_iterate(self):

def create():
return reactivex.generate_with_relative_time(
0, lambda x: True, lambda x: _raise(ex), lambda x: x + 1
0, lambda x: True, lambda x: _raise(Exception(ex)), lambda x: x + 1
)

results = scheduler.start(create)
Expand All @@ -133,7 +134,7 @@ def test_generate_datetime_offset_throw_time_mapper(self):

def create():
return reactivex.generate_with_relative_time(
0, lambda x: True, lambda x: x + 1, lambda x: _raise(ex)
0, lambda x: True, lambda x: x + 1, lambda x: _raise(Exception(ex))
)

results = scheduler.start(create)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_observable/test_last.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from typing import NoReturn

from reactivex import operators as _
from reactivex.testing import ReactiveTest, TestScheduler
Expand All @@ -17,7 +18,7 @@ class RxException(Exception):


# Helper function for raising exceptions within lambdas
def _raise(ex):
def _raise(ex: Exception) -> NoReturn:
raise RxException(ex)


Expand Down
Loading