-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
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:
FooInfo = provider(fields = {"name": "str")
BarInfo = provider(fields = {
"foos": "(depset[Foo]) the foos",
})
I would like to be able to write something like:
env.expect.that_provider(BarInfo).foos()
.contains_at_least_predicates(lambda foo: foo.name().equals("foo"))
I propose that we allow generics by turning generic types into functions. For example:
FooInfoSubject = subjects.struct(name = subjects.string)
BarInfoSubject = subjects.struct(
foos = subjects.depset(FooInfoSubject)
)
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)).
Metadata
Metadata
Assignees
Labels
No labels