summaryrefslogtreecommitdiff
path: root/git/test/lib/asserts.py
blob: a520b1ea39c0bff270318e456e9f7a741814b1de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# asserts.py
# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
#
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php

import re
from unittest.mock import patch

from nose.tools import (
    assert_equal,       # @UnusedImport
    assert_not_equal,   # @UnusedImport
    assert_raises,      # @UnusedImport
    raises,             # @UnusedImport
    assert_true,        # @UnusedImport
    assert_false        # @UnusedImport
)

__all__ = ['assert_not_none', 'assert_match',
           'assert_equal', 'assert_not_equal', 'assert_raises', 'patch', 'raises',
           'assert_true', 'assert_false']


def assert_not_none(actual, msg=None):
    """verify that item is None"""
    assert actual is not None, msg


def assert_match(pattern, string, msg=None):
    """verify that the pattern matches the string"""
    assert_not_none(re.search(pattern, string), msg)