summaryrefslogtreecommitdiff
path: root/test/testlib
diff options
context:
space:
mode:
Diffstat (limited to 'test/testlib')
-rw-r--r--test/testlib/__init__.py2
-rw-r--r--test/testlib/asserts.py42
-rw-r--r--test/testlib/helper.py8
3 files changed, 32 insertions, 20 deletions
diff --git a/test/testlib/__init__.py b/test/testlib/__init__.py
index 77512794..2133eb8c 100644
--- a/test/testlib/__init__.py
+++ b/test/testlib/__init__.py
@@ -10,4 +10,4 @@ from asserts import *
from helper import *
__all__ = [ name for name, obj in locals().items()
- if not (name.startswith('_') or inspect.ismodule(obj)) ]
+ if not (name.startswith('_') or inspect.ismodule(obj)) ]
diff --git a/test/testlib/asserts.py b/test/testlib/asserts.py
index f66af122..46fcf20e 100644
--- a/test/testlib/asserts.py
+++ b/test/testlib/asserts.py
@@ -8,31 +8,43 @@ 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'] + tools.__all__
+ '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
+ """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)
-
+ """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_equal(None, actual, msg)
+ """verify that item is None"""
+ assert actual is None, msg
def assert_not_none(actual, msg=None):
- """verify that item is None"""
- assert_not_equal(None, actual, msg)
+ """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)
+ """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) \ No newline at end of file
+ """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
diff --git a/test/testlib/helper.py b/test/testlib/helper.py
index ca262ee4..74f48447 100644
--- a/test/testlib/helper.py
+++ b/test/testlib/helper.py
@@ -9,11 +9,11 @@ import os
GIT_REPO = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
def fixture_path(name):
- test_dir = os.path.dirname(os.path.dirname(__file__))
- return os.path.join(test_dir, "fixtures", name)
+ test_dir = os.path.dirname(os.path.dirname(__file__))
+ return os.path.join(test_dir, "fixtures", name)
def fixture(name):
- return open(fixture_path(name)).read()
+ return open(fixture_path(name)).read()
def absolute_project_path():
- return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
+ return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))