Exemple #1
0
 def test_mixed_truth_restricted_type(self) -> None:
     # join_types against differently restricted truthiness types drops restrictions.
     true_any = true_only(AnyType(TypeOfAny.special_form))
     false_o = false_only(self.fx.o)
     j = join_types(true_any, false_o)
     assert_true(j.can_be_true)
     assert_true(j.can_be_false)
Exemple #2
0
 def test_mixed_truth_restricted_type_simple(self) -> None:
     # join_simple against differently restricted truthiness types drops restrictions.
     true_a = true_only(self.fx.a)
     false_o = false_only(self.fx.o)
     j = join_simple(self.fx.o, true_a, false_o)
     assert_true(j.can_be_true)
     assert_true(j.can_be_false)
Exemple #3
0
 def test_mixed_truth_restricted_type_simple(self) -> None:
     # join_simple against differently restricted truthiness types drops restrictions.
     true_a = true_only(self.fx.a)
     false_o = false_only(self.fx.o)
     j = join_simple(self.fx.o, true_a, false_o)
     assert_true(j.can_be_true)
     assert_true(j.can_be_false)
Exemple #4
0
 def test_mixed_truth_restricted_type(self) -> None:
     # join_types against differently restricted truthiness types drops restrictions.
     true_any = true_only(AnyType(TypeOfAny.special_form))
     false_o = false_only(self.fx.o)
     j = join_types(true_any, false_o)
     assert_true(j.can_be_true)
     assert_true(j.can_be_false)
Exemple #5
0
 def test_true_only_of_instance(self) -> None:
     to = true_only(self.fx.a)
     assert_equal(str(to), "A")
     assert_true(to.can_be_true)
     assert_false(to.can_be_false)
     assert_type(Instance, to)
     # The original class still can be false
     assert_true(self.fx.a.can_be_false)
Exemple #6
0
 def test_true_only_of_instance(self) -> None:
     to = true_only(self.fx.a)
     assert_equal(str(to), "A")
     assert_true(to.can_be_true)
     assert_false(to.can_be_false)
     assert_type(Instance, to)
     # The original class still can be false
     assert_true(self.fx.a.can_be_false)
Exemple #7
0
 def test_true_only_of_union(self):
     tup_type = self.tuple(AnyType())
     # Union of something that is unknown, something that is always true, something
     # that is always false
     union_type = UnionType([self.fx.a, tup_type, self.tuple()])
     to = true_only(union_type)
     assert_equal(len(to.items), 2)
     assert_true(to.items[0].can_be_true)
     assert_false(to.items[0].can_be_false)
     assert_true(to.items[1] is tup_type)
Exemple #8
0
 def test_true_only_of_true_type_is_idempotent(self) -> None:
     always_true = self.tuple(AnyType(TypeOfAny.special_form))
     to = true_only(always_true)
     assert_true(always_true is to)
Exemple #9
0
 def test_true_only_of_false_type_is_uninhabited(self) -> None:
     to = true_only(NoneType())
     assert_type(UninhabitedType, to)
Exemple #10
0
 def test_true_only_of_true_type_is_idempotent(self) -> None:
     always_true = self.tuple(AnyType(TypeOfAny.special_form))
     to = true_only(always_true)
     assert_true(always_true is to)
Exemple #11
0
 def test_true_only_of_false_type_is_uninhabited(self) -> None:
     to = true_only(NoneType())
     assert_type(UninhabitedType, to)
Exemple #12
0
 def test_true_only_of_true_type_is_idempotent(self):
     always_true = self.tuple(AnyType())
     to = true_only(always_true)
     assert_true(always_true is to)