Finishing testing promises.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ef465b34e7
commit
a182c703f4
8 changed files with 114 additions and 36 deletions
|
@ -21,7 +21,7 @@ from typing import Callable, Self
|
|||
from .base import Assertion, repr_, AssertionInterface
|
||||
from .int import NumberComparisonAssertionInterface
|
||||
|
||||
PRINT_PREFIX = (" " * 24)
|
||||
PRINT_PREFIX = (" " * 3)
|
||||
|
||||
|
||||
class SpyAssertion(Assertion):
|
||||
|
|
|
@ -30,4 +30,4 @@ class Spy:
|
|||
def __call__(self, *args, **kwargs):
|
||||
self.calls.append((args, kwargs))
|
||||
if self.function is not None:
|
||||
self.function(*args, **kwargs)
|
||||
return self.function(*args, **kwargs)
|
||||
|
|
|
@ -134,13 +134,13 @@ def test_add_natural_complex():
|
|||
assert that(2).equals.one.minus.two
|
||||
|
||||
def test_spy():
|
||||
spy = Spy()
|
||||
spy = Spy(lambda *args, **kw: 10)
|
||||
assert that(spy).is_.an.instance_of(Spy)
|
||||
assert that(spy).is_(callable)
|
||||
# Check calls
|
||||
assert that(spy).was.never.called
|
||||
assert that(spy).was.called.zero.times
|
||||
spy(30, arg="string")
|
||||
assert spy(30, arg="string") == 10
|
||||
assert that(spy).was.called
|
||||
assert that(spy).was.called.once
|
||||
assert that(spy).was.called.one.time
|
||||
|
@ -159,7 +159,7 @@ def test_spy():
|
|||
assert that(spy).was.called.with_no_argument()
|
||||
|
||||
def test_spy_seral_calls():
|
||||
spy = Spy(lambda *args, **kw: None)
|
||||
spy = Spy()
|
||||
obj = object()
|
||||
spy()
|
||||
spy(30, arg="string")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue