Skip to content

Commit e6a35c5

Browse files
committed
update test with cloning of existing repo rather than creating new branch
1 parent 3256813 commit e6a35c5

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

test/test_nonunicode.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,24 @@
2323
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
2424
# Boston, MA 02110-1301, USA.
2525

26-
"""Tests for reference objects."""
27-
28-
from pathlib import Path
26+
"""Tests for non unicode byte strings"""
2927

3028
import pygit2
31-
import pytest
32-
import subprocess
3329
import os
30+
import shutil
3431

35-
bstring_list = [b"\xc3master"]
36-
37-
38-
@pytest.fixture(params=bstring_list)
39-
def bstring(request):
40-
return request.param
4132

33+
bstring = b'\xc3master'
4234

43-
def test_nonunicode_branchname(testrepo, bstring):
44-
cmd = b"git checkout -b " + bstring
45-
subprocess.check_output(cmd.decode('utf8',errors='surrogateescape').split(" "), cwd=testrepo.workdir)
35+
def test_nonunicode_branchname(testrepo):
36+
folderpath = 'temp_repo_nonutf'
37+
if os.path.exists(folderpath):
38+
shutil.rmdir(folderpath)
4639
newrepo = pygit2.clone_repository(
47-
testrepo.workdir,
48-
os.path.join(os.path.dirname(testrepo.workdir), "test_nonunicode_repo"),
49-
)
40+
path=folderpath,
41+
url='https://github.com/pygit2/test_branch_notutf.git'
42+
)
5043
assert bstring in [
51-
branch.encode("utf8", "surrogateescape")
52-
for branch in newrepo.listall_branches()
53-
]
44+
(ref.split('/')[-1]).encode('utf8', 'surrogateescape')
45+
for ref in newrepo.listall_references()
46+
] # Remote branch among references: 'refs/remotes/origin/\udcc3master'

0 commit comments

Comments
 (0)