Add some tests for refcounts to check for leaks
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
from pygit2 import GIT_OBJ_COMMIT, Signature, Oid
|
||||
from . import utils
|
||||
@@ -46,6 +47,15 @@ COMMIT_SHA = '5fe808e8953c12735680c257f56600cb0de44b10'
|
||||
|
||||
class CommitTest(utils.BareRepoTestCase):
|
||||
|
||||
def test_commit_refcount(self):
|
||||
commit = self.repo[COMMIT_SHA]
|
||||
start = sys.getrefcount(commit)
|
||||
tree = commit.tree
|
||||
del tree
|
||||
end = sys.getrefcount(commit)
|
||||
self.assertEqual(start, end)
|
||||
|
||||
|
||||
def test_read_commit(self):
|
||||
commit = self.repo[COMMIT_SHA]
|
||||
self.assertEqual(COMMIT_SHA, str(commit.id))
|
||||
|
@@ -30,6 +30,7 @@
|
||||
|
||||
import unittest
|
||||
import pygit2
|
||||
import sys
|
||||
from pygit2 import Oid
|
||||
from . import utils
|
||||
|
||||
@@ -163,6 +164,14 @@ class RepositoryTest(utils.RepoTestCase):
|
||||
self.assertEqual('http://example.com/test.git',
|
||||
self.repo.remotes[0].url)
|
||||
|
||||
def test_remote_refcount(self):
|
||||
start = sys.getrefcount(self.repo)
|
||||
remote = self.repo.remotes[0]
|
||||
del remote
|
||||
end = sys.getrefcount(self.repo)
|
||||
|
||||
self.assertEqual(start, end)
|
||||
|
||||
def test_add_refspec(self):
|
||||
remote = self.repo.create_remote('test_add_refspec', REMOTE_URL)
|
||||
remote.add_push('refs/heads/*:refs/heads/test_refspec/*')
|
||||
|
@@ -37,6 +37,7 @@ import unittest
|
||||
import tempfile
|
||||
import os
|
||||
from os.path import join, realpath
|
||||
import sys
|
||||
|
||||
# Import from pygit2
|
||||
from pygit2 import GIT_OBJ_ANY, GIT_OBJ_BLOB, GIT_OBJ_COMMIT
|
||||
@@ -150,6 +151,14 @@ class RepositoryTest(utils.BareRepoTestCase):
|
||||
commit.message)
|
||||
self.assertRaises(ValueError, self.repo.__getitem__, too_short_prefix)
|
||||
|
||||
def test_lookup_commit_refcount(self):
|
||||
start = sys.getrefcount(self.repo)
|
||||
commit_sha = '5fe808e8953c12735680c257f56600cb0de44b10'
|
||||
commit = self.repo[commit_sha]
|
||||
del commit
|
||||
end = sys.getrefcount(self.repo)
|
||||
self.assertEqual(start, end)
|
||||
|
||||
def test_get_path(self):
|
||||
directory = realpath(self.repo.path)
|
||||
expected = realpath(self.repo_path)
|
||||
|
Reference in New Issue
Block a user