fixed errors in the test, two permission errors remaining, thx to mock?!?!
authorFlorian Apolloner <florian@apolloner.eu>
Wed, 21 May 2008 17:39:55 +0000 (19:39 +0200)
committerFlorian Apolloner <florian@apolloner.eu>
Wed, 21 May 2008 17:39:55 +0000 (19:39 +0200)
Also removed the shell_escape tests...

lib/git_python/git.py
test/git/test_git.py
test/git/test_utils.py

index 8711c1fbb68d70bd9686962a39b87f2b6e6eb54e..2cec49545614f3eda402a2f495b105bf7dbee59b 100644 (file)
@@ -25,6 +25,7 @@ class Git(MethodMissingMixin):
             The command to execute
         """
         print ' '.join(command)
+        print self.git_dir
         proc = subprocess.Popen(command,
                                 cwd = self.git_dir,
                                 stdout=subprocess.PIPE
@@ -74,7 +75,8 @@ class Git(MethodMissingMixin):
             str
         """
         opt_args = self.transform_kwargs(**kwargs)
-        args = opt_args + list(args)
+        ext_args = map(lambda a: (a == '--') and a or "%s" % a, args)
+        args = opt_args + ext_args
 
         call = ['git-'+dashify(method)]
         call.extend(args)
index 0634a5ddf339c9fa257136591fc384523233e4d7..43fd231cbe38e663999d7353dad2ada15a866d08 100644 (file)
@@ -4,9 +4,8 @@ from git_python import *
 
 class TestGit(object):
     def setup(self):
-        base = os.path.join(os.path.dirname(__file__), "../.."),
+        base = os.path.join(os.path.dirname(__file__), "../..")
         self.git = Git(base)
-        self.git_bin_base = "%s --git-dir=%s" % (Git.git_binary, base)
 
     @patch(Git, 'execute')
     def test_method_missing_calls_execute(self, git):
@@ -17,7 +16,7 @@ class TestGit(object):
     
     def test_it_transforms_kwargs_into_git_command_arguments(self):
         assert_equal(["-s"], self.git.transform_kwargs(**{'s': True}))
-        assert_equal(["-s 5"], self.git.transform_kwargs(**{'s': 5}))
+        assert_equal(["-s", 5], self.git.transform_kwargs(**{'s': 5}))
 
         assert_equal(["--max-count"], self.git.transform_kwargs(**{'max_count': True}))
         assert_equal(["--max-count=5"], self.git.transform_kwargs(**{'max_count': 5}))
@@ -25,23 +24,4 @@ class TestGit(object):
         assert_equal(["-s", "-t"], self.git.transform_kwargs(**{'s': True, 't': True}))
 
     def test_it_executes_git_to_shell_and_returns_result(self):
-        assert_match('^git version [\d\.]*$', self.git.execute("%s version" % Git.git_binary))
-
-    def test_it_transforms_kwargs_shell_escapes_arguments(self):
-        assert_equal(["--foo=\"bazz'er\""], self.git.transform_kwargs(**{'foo': "bazz'er"}))
-        assert_equal(["-x \"bazz'er\""], self.git.transform_kwargs(**{'x': "bazz'er"}))
-
-    @patch(Git, 'execute')
-    def test_it_really_shell_escapes_arguments_to_the_git_shell_1(self, git):
-        self.git.foo(**{'bar': "bazz'er"})
-        assert_true(git.called)
-        assert_equal(git.call_args, ((("%s foo --bar=\"bazz'er\"" % self.git_bin_base),), {}))
-
-    @patch(Git, 'execute')
-    def test_it_really_shell_escapes_arguments_to_the_git_shell_2(self, git):
-        self.git.bar(**{'x': "quu'x"})
-        assert_true(git.called)
-        assert_equal(git.call_args, ((("%s bar -x \"quu'x\"" % self.git_bin_base),), {}))
-
-    def test_it_shell_escapes_the_standalone_argument(self):
-        self.git.foo("bar's", {})
+        assert_match('^git version [\d\.]*$', self.git.execute(["git","version"]))
index a9af20404642ae5576b19b57d9f21ede22f1a8ec..b2b42a1c9c972784d9c82593e293705987c4b2f3 100644 (file)
@@ -6,10 +6,10 @@ class TestUtils(object):
     def setup(self):
         base = os.path.join(os.path.dirname(__file__), "../.."),
         self.git = Git(base)
-        self.git_bin_base = "%s --git-dir='%s'" % (Git.git_binary, base)
+#        self.git_bin_base = "%s --git-dir='%s'" % (Git.git_binary, base)
 
-    def test_it_escapes_single_quotes_with_shell_escape(self):
-        assert_equal("\\\\'foo", shell_escape("'foo"))
+#    def test_it_escapes_single_quotes_with_shell_escape(self):
+#        assert_equal("\\\\'foo", shell_escape("'foo"))
 
     def test_it_should_dashify(self):
         assert_equal('this-is-my-argument', dashify('this_is_my_argument'))