Skip to content

Commit

Permalink
test_nonunicode xfails in in macOS/Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavid committed Jan 18, 2025
1 parent 43bbe11 commit eff9734
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion test/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
)


@utils.refcount
@utils.requires_refcount
def test_commit_refcount(barerepo):
commit = barerepo[COMMIT_SHA]
start = sys.getrefcount(commit)
Expand Down
2 changes: 0 additions & 2 deletions test/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.

"""Tests for credentials"""

from pathlib import Path
import platform

Expand Down
7 changes: 5 additions & 2 deletions test/test_nonunicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@

"""Tests for non unicode byte strings"""

import pygit2
import os
import shutil

import pygit2
from . import utils


bstring = b'\xc3master'


@utils.requires_network
@utils.requires_linux
def test_nonunicode_branchname(testrepo):
folderpath = 'temp_repo_nonutf'
if os.path.exists(folderpath):
Expand Down
14 changes: 5 additions & 9 deletions test/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.

"""Tests for Remote objects."""

from unittest.mock import patch
import sys

import pytest

import pygit2
from pygit2 import Oid
from pygit2.ffi import ffi
from . import utils


Expand Down Expand Up @@ -220,7 +216,7 @@ def test_remote_collection(testrepo):
assert remote.name in [x.name for x in testrepo.remotes]


@utils.refcount
@utils.requires_refcount
def test_remote_refcount(testrepo):
start = sys.getrefcount(testrepo)
remote = testrepo.remotes[0]
Expand Down Expand Up @@ -272,13 +268,13 @@ def test_update_tips(emptyrepo):
tips = [
(
'refs/remotes/origin/master',
Oid(hex='0' * 40),
Oid(hex='784855caf26449a1914d2cf62d12b9374d76ae78'),
pygit2.Oid(hex='0' * 40),
pygit2.Oid(hex='784855caf26449a1914d2cf62d12b9374d76ae78'),
),
(
'refs/tags/root',
Oid(hex='0' * 40),
Oid(hex='3d2962987c695a29f1f80b6c3aa4ec046ef44369'),
pygit2.Oid(hex='0' * 40),
pygit2.Oid(hex='3d2962987c695a29f1f80b6c3aa4ec046ef44369'),
),
]

Expand Down
4 changes: 2 additions & 2 deletions test/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def test_discover_repo(tmp_path):
assert repo.path == discover_repository(str(subdir))


@utils.fspath
@utils.requires_fspath
def test_discover_repo_aspath(tmp_path):
repo = init_repository(Path(tmp_path), False)
subdir = Path(tmp_path) / 'test1' / 'test2'
Expand Down Expand Up @@ -811,7 +811,7 @@ def _check_worktree(worktree):
assert testrepo.list_worktrees() == []


@utils.fspath
@utils.requires_fspath
def test_worktree_aspath(testrepo):
worktree_name = 'foo'
worktree_dir = Path(tempfile.mkdtemp())
Expand Down
10 changes: 5 additions & 5 deletions test/test_repository_bare.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.

# Standard Library
import binascii
import os
from pathlib import Path
import pathlib
import sys
import tempfile

import pytest

import pygit2
Expand Down Expand Up @@ -160,7 +160,7 @@ def test_expand_id(barerepo):
assert commit_sha == expanded


@utils.refcount
@utils.requires_refcount
def test_lookup_commit_refcount(barerepo):
start = sys.getrefcount(barerepo)
commit_sha = '5fe808e8953c12735680c257f56600cb0de44b10'
Expand All @@ -173,7 +173,7 @@ def test_lookup_commit_refcount(barerepo):
def test_get_path(barerepo_path):
barerepo, path = barerepo_path

directory = Path(barerepo.path).resolve()
directory = pathlib.Path(barerepo.path).resolve()
assert directory == path.resolve()


Expand All @@ -199,7 +199,7 @@ def test_hashfile(barerepo):
with os.fdopen(handle, 'w') as fh:
fh.write(data)
hashed_sha1 = pygit2.hashfile(tempfile_path)
Path(tempfile_path).unlink()
pathlib.Path(tempfile_path).unlink()
written_sha1 = barerepo.create_blob(data)
assert hashed_sha1 == written_sha1

Expand Down
14 changes: 10 additions & 4 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import pygit2


requires_future_libgit2 = pytest.mark.skipif(
requires_future_libgit2 = pytest.mark.xfail(
pygit2.LIBGIT2_VER < (2, 0, 0),
reason='This test may work with a future version of libgit2',
)
Expand All @@ -58,18 +58,24 @@
requires_proxy = pytest.mark.skipif(not has_proxy, reason='Requires proxy at port 8888')

requires_ssh = pytest.mark.skipif(
pygit2.enums.Feature.SSH not in pygit2.features, reason='Requires SSH'
pygit2.enums.Feature.SSH not in pygit2.features,
reason='Requires SSH'
)


is_pypy = '__pypy__' in sys.builtin_module_names

fspath = pytest.mark.skipif(
requires_fspath = pytest.mark.xfail(
is_pypy,
reason="PyPy doesn't fully support fspath, see https://foss.heptapod.net/pypy/pypy/-/issues/3168",
)

refcount = pytest.mark.skipif(is_pypy, reason='skip refcounts checks in pypy')
requires_refcount = pytest.mark.skipif(is_pypy, reason='skip refcounts checks in pypy')

requires_linux = pytest.mark.xfail(
sys.platform != 'linux',
reason='probably a bug in libgit2 for non-linux platforms'
)


def gen_blob_sha1(data):
Expand Down

0 comments on commit eff9734

Please sign in to comment.