ソースを参照

Port hooks to python3.

Jelmer Vernooij 10 年 前
コミット
2d624bff79
2 ファイル変更11 行追加13 行削除
  1. 10 12
      dulwich/tests/test_hooks.py
  2. 1 1
      dulwich/tests/test_objects.py

+ 10 - 12
dulwich/tests/test_hooks.py

@@ -20,6 +20,7 @@
 import os
 import stat
 import shutil
+import sys
 import tempfile
 
 from dulwich import errors
@@ -31,10 +32,8 @@ from dulwich.hooks import (
 )
 
 from dulwich.tests import TestCase
-from dulwich.tests.utils import skipIfPY3
 
 
-@skipIfPY3
 class ShellHookTests(TestCase):
 
     def setUp(self):
@@ -42,11 +41,11 @@ class ShellHookTests(TestCase):
             self.skipTest('shell hook tests requires POSIX shell')
 
     def test_hook_pre_commit(self):
-        pre_commit_fail = """#!/bin/sh
+        pre_commit_fail = b"""#!/bin/sh
 exit 1
 """
 
-        pre_commit_success = """#!/bin/sh
+        pre_commit_success = b"""#!/bin/sh
 exit 0
 """
 
@@ -71,11 +70,11 @@ exit 0
 
     def test_hook_commit_msg(self):
 
-        commit_msg_fail = """#!/bin/sh
+        commit_msg_fail = b"""#!/bin/sh
 exit 1
 """
 
-        commit_msg_success = """#!/bin/sh
+        commit_msg_success = b"""#!/bin/sh
 exit 0
 """
 
@@ -90,22 +89,21 @@ exit 0
             f.write(commit_msg_fail)
         os.chmod(commit_msg, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)
 
-        self.assertRaises(errors.HookError, hook.execute, 'failed commit')
+        self.assertRaises(errors.HookError, hook.execute, b'failed commit')
 
         with open(commit_msg, 'wb') as f:
             f.write(commit_msg_success)
         os.chmod(commit_msg, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)
 
-        hook.execute('empty commit')
+        hook.execute(b'empty commit')
 
     def test_hook_post_commit(self):
 
         (fd, path) = tempfile.mkstemp()
-        post_commit_msg = """#!/bin/sh
-rm %(file)s
-""" % {'file': path}
+        post_commit_msg = b"""#!/bin/sh
+rm """ + path.encode(sys.getfilesystemencoding()) + b"\n"
 
-        post_commit_msg_fail = """#!/bin/sh
+        post_commit_msg_fail = b"""#!/bin/sh
 exit 1
 """
 

+ 1 - 1
dulwich/tests/test_objects.py

@@ -169,7 +169,7 @@ class BlobReadTests(TestCase):
         t = self.get_tree(tree_sha)
         self.assertEqual(t.items()[0], (b'a', 33188, a_sha))
         self.assertEqual(t.items()[1], (b'b', 33188, b_sha))
-        self.assertEquals(self.deserialize_count, 1)
+        self.assertEqual(self.deserialize_count, 1)
 
     def test_read_tag_from_file(self):
         t = self.get_tag(tag_sha)