from testtools.matchers import Contains assert_that('Hello, World', Contains('Hello')) assert_that('Hello, World', Contains('world', case_sensitive=False))
from testtools.matchers import Contains assert_that([1, 2, 3], Contains(2)) assert_that(['apple', 'banana', 'orange'], Contains('orange'))In this example, we are using the Contains matcher to check if the list contains the items 2 and 'orange'. Overall, the Contains matcher in testtools is a powerful tool that makes it easy to write expressive and readable unit tests in Python.