Skip to content

Commit

Permalink
Added test issues. Fixed #11
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Oct 15, 2016
1 parent 0d08c12 commit 74d8d19
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_issues.py
@@ -0,0 +1,19 @@
# This tests reported issues in the Promise package
from promise import Promise


def test_issue_11():
# https://github.com/syrusakbary/promise/issues/11
def test(x):
def my(resolve, reject):
if x > 0:
resolve(x)
else:
reject(Exception(x))
return Promise(my)

promise_resolved = test(42).then(lambda x: x)
assert promise_resolved.value == 42

promise_rejected = test(-42).then(lambda x: x, lambda e: str(e))
assert promise_rejected.value == "-42"

0 comments on commit 74d8d19

Please sign in to comment.