From 9374a916588d9fe7169937ba262c86ad710cfa74 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Oct 2009 16:49:05 +0200 Subject: converted all spaces to tabs ( 4 spaces = 1 tab ) just to allow me and my editor to work with the files properly. Can convert it back for releaes --- test/testlib/__init__.py | 2 +- test/testlib/asserts.py | 30 +++++++++++++++--------------- test/testlib/helper.py | 8 ++++---- 3 files changed, 20 insertions(+), 20 deletions(-) (limited to 'test/testlib') 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..8f2acdc9 100644 --- a/test/testlib/asserts.py +++ b/test/testlib/asserts.py @@ -10,29 +10,29 @@ from nose import tools from nose.tools import * __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'] + 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_equal(None, actual, 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_not_equal(None, actual, 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) \ 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__), "..", "..")) -- cgit v1.2.3 From 9a119924bd314934158515a1a5f5877be63f6f91 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Oct 2009 20:21:22 +0200 Subject: fixed issue in Ref.name implementation which would not handle components properly --- test/testlib/asserts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/testlib') diff --git a/test/testlib/asserts.py b/test/testlib/asserts.py index 8f2acdc9..345f74ec 100644 --- a/test/testlib/asserts.py +++ b/test/testlib/asserts.py @@ -23,11 +23,11 @@ def assert_not_instance_of(expected, actual, msg=None): def assert_none(actual, msg=None): """verify that item is None""" - assert_equal(None, actual, msg) + assert actual is None, msg def assert_not_none(actual, msg=None): """verify that item is None""" - assert_not_equal(None, actual, msg) + assert actual is not None, msg def assert_match(pattern, string, msg=None): """verify that the pattern matches the string""" -- cgit v1.2.3 From b01824b1aecf8aadae4501e22feb45c20fb26bce Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Oct 2009 22:22:28 +0200 Subject: Fixed remaining tests to deal with the changes mode is now generally an int compatible to the stat module --- test/testlib/asserts.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'test/testlib') diff --git a/test/testlib/asserts.py b/test/testlib/asserts.py index 345f74ec..46fcf20e 100644 --- a/test/testlib/asserts.py +++ b/test/testlib/asserts.py @@ -8,10 +8,12 @@ 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_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 """ @@ -35,4 +37,14 @@ def assert_match(pattern, string, msg=None): 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 + 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 -- cgit v1.2.3 From a58a60ac5f322eb4bfd38741469ff21b5a33d2d5 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 12 Oct 2009 23:18:43 +0200 Subject: tree: now behaves like a list with string indexing functionality - using a dict as cache is a problem as the tree is ordered, added blobs, trees and traverse method repo: remove blob function as blobs are created directly or iterated - primitve types should not clutter the repo interface --- test/testlib/__init__.py | 1 + 1 file changed, 1 insertion(+) (limited to 'test/testlib') diff --git a/test/testlib/__init__.py b/test/testlib/__init__.py index 2133eb8c..f364171b 100644 --- a/test/testlib/__init__.py +++ b/test/testlib/__init__.py @@ -8,6 +8,7 @@ import inspect from mock import * from asserts import * from helper import * +from unittest import TestCase __all__ = [ name for name, obj in locals().items() if not (name.startswith('_') or inspect.ismodule(obj)) ] -- cgit v1.2.3 From ead94f267065bb55303f79a0a6df477810b3c68d Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 14 Oct 2009 14:33:51 +0200 Subject: cmd: added option to return the process directly, allowing to read the output directly from the output stream commit: now reads commit information directly from the output stream of the process by implementing its iterator method repo: removed log method as it was redundant ( equal to the commits method ) --- test/testlib/helper.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/testlib') diff --git a/test/testlib/helper.py b/test/testlib/helper.py index 74f48447..b66d3eaa 100644 --- a/test/testlib/helper.py +++ b/test/testlib/helper.py @@ -17,3 +17,14 @@ def fixture(name): def absolute_project_path(): return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) + + +class ListProcessAdapter(object): + """Allows to use lists as Process object as returned by SubProcess.Popen. + Its tailored to work with the test system only""" + + def __init__(self, input_list_or_string): + l = input_list_or_string + if isinstance(l,basestring): + l = l.splitlines() + self.stdout = iter(l) -- cgit v1.2.3