diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-11-21 19:19:04 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-11-21 19:19:04 +0100 |
commit | e6019e16d5a74dc49eb7129ee7fd78b4de51dac2 (patch) | |
tree | d63ba4a29087506bb1906307f202d11e22c6979c /test/lib/asserts.py | |
parent | fafe8a77db75083de3e7af92185ecdb7f2d542d3 (diff) | |
download | gitpython-e6019e16d5a74dc49eb7129ee7fd78b4de51dac2.tar.gz |
flattened test folder structure, didn't adjust any file content yet
Diffstat (limited to 'test/lib/asserts.py')
-rw-r--r-- | test/lib/asserts.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/lib/asserts.py b/test/lib/asserts.py new file mode 100644 index 00000000..fa754b92 --- /dev/null +++ b/test/lib/asserts.py @@ -0,0 +1,50 @@ +# 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 +import unittest +from nose import tools +from nose.tools import * +import stat + +__all__ = ['assert_instance_of', 'assert_not_instance_of', + 'assert_none', 'assert_not_none', + 'assert_match', 'assert_not_match', 'assert_mode_644', + 'assert_mode_755'] + tools.__all__ + +def assert_instance_of(expected, actual, msg=None): + """Verify that object is an instance of expected """ + assert isinstance(actual, expected), msg + +def assert_not_instance_of(expected, actual, msg=None): + """Verify that object is not an instance of expected """ + assert not isinstance(actual, expected, msg) + +def assert_none(actual, msg=None): + """verify that item is None""" + assert actual is None, msg + +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) + +def assert_not_match(pattern, string, msg=None): + """verify that the pattern does not match the string""" + assert_none(re.search(pattern, string), msg) + +def assert_mode_644(mode): + """Verify given mode is 644""" + assert (mode & stat.S_IROTH) and (mode & stat.S_IRGRP) + assert (mode & stat.S_IWUSR) and (mode & stat.S_IRUSR) and not (mode & stat.S_IXUSR) + +def assert_mode_755(mode): + """Verify given mode is 755""" + assert (mode & stat.S_IROTH) and (mode & stat.S_IRGRP) and (mode & stat.S_IXOTH) and (mode & stat.S_IXGRP) + assert (mode & stat.S_IWUSR) and (mode & stat.S_IRUSR) and (mode & stat.S_IXUSR)
\ No newline at end of file |