|
23 | 23 | # the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
24 | 24 | # Boston, MA 02110-1301, USA. |
25 | 25 |
|
26 | | -"""Tests for reference objects.""" |
27 | | - |
28 | | -from pathlib import Path |
| 26 | +"""Tests for non unicode byte strings""" |
29 | 27 |
|
30 | 28 | import pygit2 |
31 | | -import pytest |
32 | | -import subprocess |
33 | 29 | import os |
| 30 | +import shutil |
34 | 31 |
|
35 | | -bstring_list = [b"\xc3master"] |
36 | | - |
37 | | - |
38 | | -@pytest.fixture(params=bstring_list) |
39 | | -def bstring(request): |
40 | | - return request.param |
41 | 32 |
|
| 33 | +bstring = b'\xc3master' |
42 | 34 |
|
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) |
46 | 39 | 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 | + ) |
50 | 43 | 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