|
1
|
|
|
from hamcrest import assert_that, equal_to |
|
2
|
|
|
from hamcrest.core.string_description import StringDescription |
|
3
|
|
|
from hamcrest.library.bool import is_false, is_true |
|
4
|
|
|
from hamcrest_unit_test.matcher_test import MatcherTest |
|
5
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
class BoolComparisonTest(MatcherTest): |
|
8
|
|
|
def test_true_is_true(self): |
|
9
|
|
|
self.assert_matches('Is True', is_true(), True) |
|
10
|
|
|
|
|
11
|
|
|
def test_false_is_not_true(self): |
|
12
|
|
|
self.assert_does_not_match('False', is_true(), False) |
|
13
|
|
|
|
|
14
|
|
|
def test_false_is_false(self): |
|
15
|
|
|
self.assert_matches('False', is_false(), False) |
|
16
|
|
|
|
|
17
|
|
|
def test_true_is_not_false(self): |
|
18
|
|
|
self.assert_does_not_match('True', is_false(), True) |
|
19
|
|
|
|
|
20
|
|
|
def test_number_is_not_true(self): |
|
21
|
|
|
self.assert_does_not_match('True', is_true(), 1) |
|
22
|
|
|
|
|
23
|
|
|
def test_number_is_not_false(self): |
|
24
|
|
|
self.assert_does_not_match('False', is_false(), 1) |
|
25
|
|
|
|
|
26
|
|
|
def test_is_true_description(self): |
|
27
|
|
|
description = StringDescription() |
|
28
|
|
|
is_true().describe_to(description) |
|
29
|
|
|
assert_that(str(description), equal_to('True')) |
|
30
|
|
|
|
|
31
|
|
|
def test_is_false_description(self): |
|
32
|
|
|
description = StringDescription() |
|
33
|
|
|
is_false().describe_to(description) |
|
34
|
|
|
assert_that(str(description), equal_to('False')) |
|
35
|
|
|
|