Hi,

You can use matchers from hamcrest module. For example, assuming your
pcollection consists of a single list, you can use something like this to
test if it contains a subset:

import hamcrest as hc
assert_that(pcoll, matches_all([hc.has_items(1, 3, 6, 10)]))

Thanks,
Kamil

On Tue, Feb 25, 2020 at 7:24 PM Liu Wang <liuw...@google.com> wrote:

> Hi,
>
> As far as I know, the matchers I can use with assert_that are
> equal_to and matches_all in this file:
>
> https://github.com/apache/beam/blob/master/sdks/python/apache_beam/testing/util.py
>
> Is there any matcher that I can test a PCollection contains a subset?
> Is there any matcher that I can test a PCollection contains any number of
> a specific element?
>
> For example, I want to test the PCollection [1, 3, 6, 10, 15, 15, 15]
> contains [1, 3, 6, 10], and it contains any number of 15s.
>
> Thanks,
> Liu
>

Reply via email to