You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's currently very hard to work with custom providers. One example of somewhere seriously lacking is if I want to do assertions on the following type:
This would make the above predicates far more easily implemented (although the caveat is that it would require a change in matchers so that you could simply use them as a boolean predicate - at the moment, not matching simply fails the test).
We could also use this to easily solve #63 via the generic type subjects.optional (eg. subjects.optional(subjects.string)).
The text was updated successfully, but these errors were encountered:
FWIW, I've mostly solved this by just doing the following:
# I strongly dislike how struct is defined, IMO the attrs should be currieddefstruct(**attrs):
returnlambdavalue, *, meta: subjects.struct(value, meta=meta, attrs=attrs)
defoptional(factory):
defnew_factory(value, *, meta):
# Optimisations could be done here to just pull all the methods from the parent and add the method is_none()defsome():
ifvalue==None:
meta.add_failure("Wanted a value, but got None", None)
returnfactory(value, meta=meta)
defis_none():
ifvalue!=None:
meta.add_failure("Wanted None, but got a value", value)
returnstruct(some=some, is_none=is_none)
generic_subjects=struct(struct=struct, optional=optional)
It's currently very hard to work with custom providers. One example of somewhere seriously lacking is if I want to do assertions on the following type:
I would like to be able to write something like:
I propose that we allow generics by turning generic types into functions. For example:
This would make the above predicates far more easily implemented (although the caveat is that it would require a change in matchers so that you could simply use them as a boolean predicate - at the moment, not matching simply fails the test).
We could also use this to easily solve #63 via the generic type
subjects.optional
(eg.subjects.optional(subjects.string)
).The text was updated successfully, but these errors were encountered: