|
| 1 | +# Copyright 2010-2024 The pygit2 contributors |
| 2 | +# |
| 3 | +# This file is free software; you can redistribute it and/or modify |
| 4 | +# it under the terms of the GNU General Public License, version 2, |
| 5 | +# as published by the Free Software Foundation. |
| 6 | +# |
| 7 | +# In addition to the permissions in the GNU General Public License, |
| 8 | +# the authors give you unlimited permission to link the compiled |
| 9 | +# version of this file into combinations with other programs, |
| 10 | +# and to distribute those combinations without any restriction |
| 11 | +# coming from the use of this file. (The General Public License |
| 12 | +# restrictions do apply in other respects; for example, they cover |
| 13 | +# modification of the file, and distribution when not linked into |
| 14 | +# a combined executable.) |
| 15 | +# |
| 16 | +# This file is distributed in the hope that it will be useful, but |
| 17 | +# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 | +# General Public License for more details. |
| 20 | +# |
| 21 | +# You should have received a copy of the GNU General Public License |
| 22 | +# along with this program; see the file COPYING. If not, write to |
| 23 | +# the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
| 24 | +# Boston, MA 02110-1301, USA. |
| 25 | + |
| 26 | +"""Tests for non unicode byte strings""" |
| 27 | + |
| 28 | +import pygit2 |
| 29 | +import os |
| 30 | +import shutil |
| 31 | + |
| 32 | + |
| 33 | +bstring = b'\xc3master' |
| 34 | + |
| 35 | +def test_nonunicode_branchname(testrepo): |
| 36 | + folderpath = 'temp_repo_nonutf' |
| 37 | + if os.path.exists(folderpath): |
| 38 | + shutil.rmtree(folderpath) |
| 39 | + newrepo = pygit2.clone_repository( |
| 40 | + path=folderpath, url='https://github.com/pygit2/test_branch_notutf.git' |
| 41 | + ) |
| 42 | + assert bstring in [ |
| 43 | + (ref.split('/')[-1]).encode('utf8', 'surrogateescape') |
| 44 | + for ref in newrepo.listall_references() |
| 45 | + ] # Remote branch among references: 'refs/remotes/origin/\udcc3master' |
0 commit comments