def test_objects_with_required_and_optional_fields(self): st = json.objects(required_fields={'always': json.booleans()}, optional_fields={'maybe': json.booleans()}) self.assertEqual(hypothesis.find( st, lambda v: v['always'] and 'maybe' not in v), {'always': True}) self.assertEqual(hypothesis.find( st, lambda v: v['always'] and 'maybe' in v), {'always': True, 'maybe': False})
def test_booleans(self): st = json.booleans() value = hypothesis.find(st, lambda _: True) self.assertIsInstance(value, bool) self.assertFalse(value)