summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Aguilar <davvid@gmail.com>2008-05-29 02:03:18 -0700
committerDavid Aguilar <davvid@gmail.com>2008-05-29 02:03:18 -0700
commitdc922f3678a1b01cac2b3f1ec74b831ffec52a71 (patch)
treee75eb8921a18e28010d14f01d02a864419d7c40b
parent2405cf54ac06140a0821f55b34c1d54f699e8e73 (diff)
downloadgitpython-dc922f3678a1b01cac2b3f1ec74b831ffec52a71.tar.gz
tests: add a test for git.foo( istream=fh )
This test runs the equivalent of: "git hash-object < fixtures/cat_file_blob" with the new istream mechanism and compares the computed hash. Signed-off-by: David Aguilar <davvid@gmail.com>
-rw-r--r--test/git/test_git.py7
-rw-r--r--test/testlib/helper.py13
2 files changed, 15 insertions, 5 deletions
diff --git a/test/git/test_git.py b/test/git/test_git.py
index cae75672..8ea9b8ef 100644
--- a/test/git/test_git.py
+++ b/test/git/test_git.py
@@ -25,3 +25,10 @@ class TestGit(object):
def test_it_executes_git_to_shell_and_returns_result(self):
assert_match('^git version [\d\.]*$', self.git.execute(["git","version"]))
+
+ def test_it_accepts_stdin(self):
+ filename = fixture_path("cat_file_blob")
+ fh = open(filename, 'r')
+ assert_equal( "70c379b63ffa0795fdbfbc128e5a2818397b7ef8",
+ self.git.hash_object(istream=fh, stdin=True) )
+ fh.close()
diff --git a/test/testlib/helper.py b/test/testlib/helper.py
index 19cff8f5..0e3f6bf5 100644
--- a/test/testlib/helper.py
+++ b/test/testlib/helper.py
@@ -1,10 +1,13 @@
import os
-GIT_REPO = os.path.join(os.path.dirname(__file__), "..", "..")
+GIT_REPO = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
-def fixture(name):
- file = open(os.path.join(os.path.dirname(__file__), "..", "fixtures", name))
- return file.read()
+def fixture_path(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()
def absolute_project_path():
- return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) \ No newline at end of file
+ return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))