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)
|
||||
|
||||
# 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:
|
||||
ccred = get_credentials(credentials, url, username, allowed)
|
||||
cred_out[0] = ccred[0]
|
||||
|
||||
except Passthrough as e:
|
||||
return C.GIT_PASSTHROUGH
|
||||
except Exception as e:
|
||||
if e is Passthrough:
|
||||
return C.GIT_PASSTHROUGH
|
||||
|
||||
self._stored_exception = e
|
||||
return C.GIT_EUSER
|
||||
|
||||
@ -308,15 +306,14 @@ class RemoteCallbacks(object):
|
||||
val = certificate_check(None, bool(valid), ffi.string(host))
|
||||
if not val:
|
||||
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:
|
||||
if e is Passthrough:
|
||||
if is_ssh:
|
||||
return 0
|
||||
elif valid:
|
||||
return 0
|
||||
else:
|
||||
return C.GIT_ECERTIFICATE
|
||||
|
||||
self._stored_exception = e
|
||||
return C.GIT_EUSER
|
||||
|
||||
|
@ -33,6 +33,7 @@ import pygit2
|
||||
import sys
|
||||
from pygit2 import Oid
|
||||
from . import utils
|
||||
import gc
|
||||
|
||||
try:
|
||||
import __pypy__
|
||||
@ -238,6 +239,11 @@ class PushTestCase(unittest.TestCase):
|
||||
self.remote = self.clone.create_remote('origin', self.origin.path)
|
||||
|
||||
def tearDown(self):
|
||||
self.origin = None
|
||||
self.clone = None
|
||||
self.remote = None
|
||||
gc.collect()
|
||||
|
||||
self.origin_ctxtmgr.__exit__(None, None, None)
|
||||
self.clone_ctxtmgr.__exit__(None, None, None)
|
||||
|
||||
|
@ -41,6 +41,12 @@ import sys
|
||||
|
||||
import six
|
||||
|
||||
if six.PY2:
|
||||
from urllib import pathname2url
|
||||
|
||||
if six.PY3:
|
||||
from urllib.request import pathname2url
|
||||
|
||||
# Import from pygit2
|
||||
from pygit2 import GIT_OBJ_ANY, GIT_OBJ_BLOB, GIT_OBJ_COMMIT
|
||||
from pygit2 import init_repository, clone_repository, discover_repository
|
||||
@ -192,8 +198,8 @@ class RepositoryTest(utils.BareRepoTestCase):
|
||||
|
||||
def test_hashfile(self):
|
||||
data = "bazbarfoo"
|
||||
tempfile_path = tempfile.mkstemp()[1]
|
||||
with open(tempfile_path, 'w') as fh:
|
||||
handle, tempfile_path = tempfile.mkstemp()
|
||||
with os.fdopen(handle, 'w') as fh:
|
||||
fh.write(data)
|
||||
hashed_sha1 = hashfile(tempfile_path)
|
||||
os.unlink(tempfile_path)
|
||||
@ -513,7 +519,7 @@ class CloneRepositoryTest(utils.NoRepoTestCase):
|
||||
def test_clone_repository_and_remote_callbacks(self):
|
||||
src_repo_relpath = "./test/data/testrepo.git/"
|
||||
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):
|
||||
return init_repository(path, bare)
|
||||
|
Loading…
x
Reference in New Issue
Block a user