Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit cddbcf2

Browse files
committed
async is async_mode in python3.7 and newer
1 parent 1863bca commit cddbcf2

File tree

10 files changed

+31
-19
lines changed

10 files changed

+31
-19
lines changed

CHANGES.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
20190405
2+
========
3+
4+
- Release 1.9.2
5+
- async() matcher is available as async_mode() for python3.7 and newer
6+
7+
18
20141126
29
========
310

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
doublex (1.9.2-1) unstable; urgency=low
2+
3+
* New release
4+
5+
-- David Villa Alises <David.Villa@gmail.com> Fri, 05 Apr 2019 11:24:14 +0200
6+
17
doublex (1.9.1-2) unstable; urgency=low
28

39
* New release

docs/api.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ for Spy methods
8686

8787
See :ref:`called`.
8888

89-
.. py:method:: called.async(timeout)
89+
.. py:method:: called.async_mode(timeout)
9090
9191
The ``called`` assertion waits the corresponding invocation a maximum of `timeout`
9292
seconds.
@@ -95,9 +95,9 @@ for Spy methods
9595

9696
::
9797

98-
assert_that(spy.method, called().async(1))
98+
assert_that(spy.method, called().async_mode(1))
9999

100-
See :ref:`async`.
100+
See :ref:`async_mode`.
101101

102102

103103
.. py:method:: called.times(value)

docs/async-spies.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _async:
1+
.. async_mode:
22
33
Asynchronous spies
44
==================
@@ -86,7 +86,7 @@ barrier. If the ``write()`` invocation never happens, the ``barrier.wait()`` con
8686
after 1 second but the test fails, as must do. When all is right, the barrier waits just
8787
the required time.
8888

89-
Well, this mechanism is a doublex builtin (the ``async`` matcher) since release 1.5.1
89+
Well, this mechanism is a doublex builtin (the ``async_mode`` matcher) since release 1.5.1
9090
providing the same behavior in a clearer way. The next is functionally equivalent to the
9191
listing just above:
9292

@@ -104,7 +104,7 @@ listing just above:
104104
sut.some_method()
105105

106106
# then
107-
assert_that(spy.write, called().async(timeout=1))
107+
assert_that(spy.write, called().async_mode(timeout=1))
108108

109109

110110
.. Local Variables:

docs/async-spies.rst.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _async:
1+
.. async_mode:
22

33
Asynchronous spies
44
==================
@@ -86,7 +86,7 @@ barrier. If the ``write()`` invocation never happens, the ``barrier.wait()`` con
8686
after 1 second but the test fails, as must do. When all is right, the barrier waits just
8787
the required time.
8888

89-
Well, this mechanism is a doublex builtin (the ``async`` matcher) since release 1.5.1
89+
Well, this mechanism is a doublex builtin (the ``async_mode`` matcher) since release 1.5.1
9090
providing the same behavior in a clearer way. The next is functionally equivalent to the
9191
listing just above:
9292

@@ -104,7 +104,7 @@ listing just above:
104104
sut.some_method()
105105

106106
# then
107-
assert_that(spy.write, called().async(timeout=1))
107+
assert_that(spy.write, called().async_mode(timeout=1))
108108

109109

110110
.. Local Variables:

doublex/internal.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,12 @@ def delegates(self, delegate):
201201
def returns(self, value):
202202
self.context.retval = value
203203
self.delegates(func_returning(value))
204-
return self
205204

206205
def returns_input(self):
207206
if not self.context.args:
208207
raise TypeError("%s has no input args" % self)
209208

210209
self.delegates(func_returning_input(self))
211-
return self
212210

213211
def raises(self, e):
214212
self.delegates(func_raising(e))

doublex/matchers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def _matches(self, method):
9898

9999
if self._async_timeout:
100100
if self._times != any_time:
101-
raise WrongApiUsage("'times' and 'async' are exclusive")
101+
raise WrongApiUsage("'times' and 'async_mode' are exclusive")
102102
self.method._event.wait(self._async_timeout)
103103

104104
return method._was_called(self.context, self._times)
@@ -127,7 +127,7 @@ def with_some_args(self, **kargs):
127127
self.context.check_some_args = True
128128
return self
129129

130-
def _async(self, timeout):
130+
def async_mode(self, timeout):
131131
self._async_timeout = timeout
132132
return self
133133

@@ -136,8 +136,9 @@ def times(self, n):
136136
return self
137137

138138

139+
# backward compatibility
139140
if sys.version_info < (3, 7):
140-
setattr(MethodCalled, 'async', MethodCalled._async)
141+
setattr(MethodCalled, 'async', MethodCalled.async_mode)
141142

142143

143144
def called():

doublex/test/async_race_condition_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ def test_wrong_try_to_test_an_async_invocation(self):
4141
sut.some_method()
4242

4343
# then
44-
assert_that(spy.write, called()._async(1))
44+
assert_that(spy.write, called().async_mode(1))

doublex/test/unit_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ def test_spy_call_with_async_feature(self):
13451345
sut.send_data()
13461346

13471347
# then
1348-
assert_that(spy.write, called()._async(timeout=1))
1348+
assert_that(spy.write, called().async_mode(timeout=1))
13491349

13501350
def test_spy_async_support_1_call_only(self):
13511351
# given
@@ -1358,7 +1358,7 @@ def test_spy_async_support_1_call_only(self):
13581358

13591359
# then
13601360
with self.assertRaises(WrongApiUsage):
1361-
assert_that(spy.write, called()._async(timeout=1).with_args(3).times(2))
1361+
assert_that(spy.write, called().async_mode(timeout=1).with_args(3).times(2))
13621362

13631363
def test_spy_async_stubbed(self):
13641364
# given
@@ -1371,7 +1371,7 @@ def test_spy_async_stubbed(self):
13711371
sut.send_data(3)
13721372

13731373
# then
1374-
assert_that(spy.write, called()._async(timeout=1))
1374+
assert_that(spy.write, called().async_mode(timeout=1))
13751375

13761376

13771377
# new on 1.7

version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.9.1'
1+
__version__ = '1.9.2'

0 commit comments

Comments
 (0)