Fix windows tests
This commit is contained in:
parent
e2393a5e24
commit
00dd78bf1b
@ -64,4 +64,6 @@ def check_error(err, io=False):
|
|||||||
raise GitError(message)
|
raise GitError(message)
|
||||||
|
|
||||||
# Indicate that we want libgit2 to pretend a function was not set
|
# Indicate that we want libgit2 to pretend a function was not set
|
||||||
Passthrough = Exception("The function asked for pass-through")
|
class Passthrough(Exception):
|
||||||
|
def __init__(self):
|
||||||
|
super(Passthrough, self).__init__( "The function asked for pass-through")
|
||||||
|
@ -278,11 +278,9 @@ class RemoteCallbacks(object):
|
|||||||
try:
|
try:
|
||||||
ccred = get_credentials(credentials, url, username, allowed)
|
ccred = get_credentials(credentials, url, username, allowed)
|
||||||
cred_out[0] = ccred[0]
|
cred_out[0] = ccred[0]
|
||||||
|
except Passthrough as e:
|
||||||
|
return C.GIT_PASSTHROUGH
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if e is Passthrough:
|
|
||||||
return C.GIT_PASSTHROUGH
|
|
||||||
|
|
||||||
self._stored_exception = e
|
self._stored_exception = e
|
||||||
return C.GIT_EUSER
|
return C.GIT_EUSER
|
||||||
|
|
||||||
@ -308,15 +306,14 @@ class RemoteCallbacks(object):
|
|||||||
val = certificate_check(None, bool(valid), ffi.string(host))
|
val = certificate_check(None, bool(valid), ffi.string(host))
|
||||||
if not val:
|
if not val:
|
||||||
return C.GIT_ECERTIFICATE
|
return C.GIT_ECERTIFICATE
|
||||||
|
except Passthrough as e:
|
||||||
|
if is_ssh:
|
||||||
|
return 0
|
||||||
|
elif valid:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
return C.GIT_ECERTIFICATE
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if e is Passthrough:
|
|
||||||
if is_ssh:
|
|
||||||
return 0
|
|
||||||
elif valid:
|
|
||||||
return 0
|
|
||||||
else:
|
|
||||||
return C.GIT_ECERTIFICATE
|
|
||||||
|
|
||||||
self._stored_exception = e
|
self._stored_exception = e
|
||||||
return C.GIT_EUSER
|
return C.GIT_EUSER
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ import pygit2
|
|||||||
import sys
|
import sys
|
||||||
from pygit2 import Oid
|
from pygit2 import Oid
|
||||||
from . import utils
|
from . import utils
|
||||||
|
import gc
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import __pypy__
|
import __pypy__
|
||||||
@ -238,6 +239,11 @@ class PushTestCase(unittest.TestCase):
|
|||||||
self.remote = self.clone.create_remote('origin', self.origin.path)
|
self.remote = self.clone.create_remote('origin', self.origin.path)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
self.origin = None
|
||||||
|
self.clone = None
|
||||||
|
self.remote = None
|
||||||
|
gc.collect()
|
||||||
|
|
||||||
self.origin_ctxtmgr.__exit__(None, None, None)
|
self.origin_ctxtmgr.__exit__(None, None, None)
|
||||||
self.clone_ctxtmgr.__exit__(None, None, None)
|
self.clone_ctxtmgr.__exit__(None, None, None)
|
||||||
|
|
||||||
|
@ -41,6 +41,12 @@ import sys
|
|||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
if six.PY2:
|
||||||
|
from urllib import pathname2url
|
||||||
|
|
||||||
|
if six.PY3:
|
||||||
|
from urllib.request import pathname2url
|
||||||
|
|
||||||
# Import from pygit2
|
# Import from pygit2
|
||||||
from pygit2 import GIT_OBJ_ANY, GIT_OBJ_BLOB, GIT_OBJ_COMMIT
|
from pygit2 import GIT_OBJ_ANY, GIT_OBJ_BLOB, GIT_OBJ_COMMIT
|
||||||
from pygit2 import init_repository, clone_repository, discover_repository
|
from pygit2 import init_repository, clone_repository, discover_repository
|
||||||
@ -192,8 +198,8 @@ class RepositoryTest(utils.BareRepoTestCase):
|
|||||||
|
|
||||||
def test_hashfile(self):
|
def test_hashfile(self):
|
||||||
data = "bazbarfoo"
|
data = "bazbarfoo"
|
||||||
tempfile_path = tempfile.mkstemp()[1]
|
handle, tempfile_path = tempfile.mkstemp()
|
||||||
with open(tempfile_path, 'w') as fh:
|
with os.fdopen(handle, 'w') as fh:
|
||||||
fh.write(data)
|
fh.write(data)
|
||||||
hashed_sha1 = hashfile(tempfile_path)
|
hashed_sha1 = hashfile(tempfile_path)
|
||||||
os.unlink(tempfile_path)
|
os.unlink(tempfile_path)
|
||||||
@ -513,7 +519,7 @@ class CloneRepositoryTest(utils.NoRepoTestCase):
|
|||||||
def test_clone_repository_and_remote_callbacks(self):
|
def test_clone_repository_and_remote_callbacks(self):
|
||||||
src_repo_relpath = "./test/data/testrepo.git/"
|
src_repo_relpath = "./test/data/testrepo.git/"
|
||||||
repo_path = os.path.join(self._temp_dir, "clone-into")
|
repo_path = os.path.join(self._temp_dir, "clone-into")
|
||||||
url = 'file://' + os.path.realpath(src_repo_relpath)
|
url = 'file:' + pathname2url(os.path.realpath(src_repo_relpath))
|
||||||
|
|
||||||
def create_repository(path, bare):
|
def create_repository(path, bare):
|
||||||
return init_repository(path, bare)
|
return init_repository(path, bare)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user