Python testtools.matchers() Examples

The following are 2 code examples of testtools.matchers(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module testtools , or try the search function .
Example #1
Source File: testcase.py    From maas with GNU Affero General Public License v3.0 5 votes vote down vote up
def checkDatabaseUse(self):
        """Enforce `database_use_permitted`."""
        if self.database_use_possible and not self.database_use_permitted:
            from django.db import connection

            self.expectThat(
                connection.connection,
                testtools.matchers.Is(None),
                "Test policy forbids use of the database.",
            )
            connection.close() 
Example #2
Source File: testcase.py    From maas with GNU Affero General Public License v3.0 5 votes vote down vote up
def assertAttributes(self, tested_object, attributes):
        """Check multiple attributes of `tested_object` against a dict.

        :param tested_object: Any object whose attributes should be checked.
        :param attributes: A dict of attributes to test, and their expected
            values.  Only these attributes will be checked.
        """
        matcher = testtools.matchers.MatchesStructure.byEquality(**attributes)
        self.assertThat(tested_object, matcher)