コード例 #1
0
 def test_round_trip(self):
     schema = schemas.PredicateSchema()
     statement = schema.load(
         {"content": "{}'s favorite number is {}", "quantity": 42}
     )
     dumped = to_dict(statement)
     new_statement = schema.load(dumped)
     assert "{}'s favorite number is exactly equal to 42" in str(new_statement)
コード例 #2
0
 def test_make_comparison_when_absent(self):
     schema = schemas.PredicateSchema()
     statement = schema.load(
         {"content": "{}'s favorite number is {}", "quantity": 42}
     )
     assert statement.comparison == "="
     assert "{}'s favorite number is exactly equal to 42" in str(statement)
     assert len(statement) == 1
コード例 #3
0
 def test_load_and_normalize_quantity(self):
     schema = schemas.PredicateSchema()
     p7 = schema.load(
         data={
             "content": "the distance between {} and {} was != 35 feet",
             "truth": True,
             "reciprocal": True,
         }
     )
     assert p7.comparison == "<>"
コード例 #4
0
 def test_load_comparison(self):
     schema = schemas.PredicateSchema()
     p7 = schema.load(
         {
             "content": "the distance between {} and {} was {}",
             "truth": True,
             "reciprocal": True,
             "comparison": "!=",
             "quantity": "35 feet",
         }
     )
     assert p7.comparison == "<>"
コード例 #5
0
 def test_load_just_content(self):
     schema = schemas.PredicateSchema()
     p4 = schema.load({"content": "{} was on the premises of {}"})
     assert p4.truth is True
     assert p4.comparison == ""