55"""Test for object db"""
66import tempfile
77import os
8+ import sys
89
910from gitdb .test .lib import TestBase
1011from gitdb .util import (
@@ -19,14 +20,14 @@ class TestUtils(TestBase):
1920 def test_basics (self ):
2021 assert to_hex_sha (NULL_HEX_SHA ) == NULL_HEX_SHA
2122 assert len (to_bin_sha (NULL_HEX_SHA )) == 20
22- assert to_hex_sha (to_bin_sha (NULL_HEX_SHA )) == NULL_HEX_SHA
23+ assert to_hex_sha (to_bin_sha (NULL_HEX_SHA )) == NULL_HEX_SHA . encode ( "ascii" )
2324
2425 def _cmp_contents (self , file_path , data ):
2526 # raise if data from file at file_path
2627 # does not match data string
2728 fp = open (file_path , "rb" )
2829 try :
29- assert fp .read () == data
30+ assert fp .read () == data . encode ( "ascii" )
3031 finally :
3132 fp .close ()
3233
@@ -35,7 +36,7 @@ def test_lockedfd(self):
3536 orig_data = "hello"
3637 new_data = "world"
3738 my_file_fp = open (my_file , "wb" )
38- my_file_fp .write (orig_data )
39+ my_file_fp .write (orig_data . encode ( "ascii" ) )
3940 my_file_fp .close ()
4041
4142 try :
@@ -53,7 +54,7 @@ def test_lockedfd(self):
5354 assert os .path .isfile (lockfilepath )
5455
5556 # write data and fail
56- os .write (wfd , new_data )
57+ os .write (wfd , new_data . encode ( "ascii" ) )
5758 lfd .rollback ()
5859 assert lfd ._fd is None
5960 self ._cmp_contents (my_file , orig_data )
@@ -66,7 +67,7 @@ def test_lockedfd(self):
6667 # test reading
6768 lfd = LockedFD (my_file )
6869 rfd = lfd .open (write = False )
69- assert os .read (rfd , len (orig_data )) == orig_data
70+ assert os .read (rfd , len (orig_data )) == orig_data . encode ( "ascii" )
7071
7172 assert os .path .isfile (lockfilepath )
7273 # deletion rolls back
@@ -83,7 +84,7 @@ def test_lockedfd(self):
8384 # another one fails
8485 self .failUnlessRaises (IOError , olfd .open )
8586
86- wfdstream .write (new_data )
87+ wfdstream .write (new_data . encode ( "ascii" ) )
8788 lfd .commit ()
8889 assert not os .path .isfile (lockfilepath )
8990 self ._cmp_contents (my_file , new_data )
0 commit comments