mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-17 08:43:50 +01:00
update tests for new defaults
This commit is contained in:
parent
54ab1151f1
commit
145401de33
30 changed files with 495 additions and 417 deletions
|
|
@ -1,47 +0,0 @@
|
|||
# This file is part of the pycalver project
|
||||
# https://github.com/mbarkhau/pycalver
|
||||
#
|
||||
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
|
||||
# SPDX-License-Identifier: MIT
|
||||
import sys
|
||||
import typing as typ
|
||||
|
||||
PY2 = sys.version_info.major < 3
|
||||
|
||||
|
||||
try:
|
||||
from urllib.parse import quote as py3_stdlib_quote
|
||||
except ImportError:
|
||||
from urllib import quote as py2_stdlib_quote # type: ignore
|
||||
|
||||
|
||||
# NOTE (mb 2016-05-23): quote in python2 expects bytes argument.
|
||||
|
||||
|
||||
def quote(
|
||||
string : str,
|
||||
safe : str = "/",
|
||||
encoding: typ.Optional[str] = None,
|
||||
errors : typ.Optional[str] = None,
|
||||
) -> str:
|
||||
if not isinstance(string, str):
|
||||
errmsg = f"Expected str/unicode but got {type(string)}" # type: ignore
|
||||
raise TypeError(errmsg)
|
||||
|
||||
if encoding is None:
|
||||
_encoding = "utf-8"
|
||||
else:
|
||||
_encoding = encoding
|
||||
|
||||
if errors is None:
|
||||
_errors = "strict"
|
||||
else:
|
||||
_errors = errors
|
||||
|
||||
if PY2:
|
||||
data = string.encode(_encoding)
|
||||
|
||||
res = py2_stdlib_quote(data, safe=safe.encode(_encoding))
|
||||
return res.decode(_encoding, errors=_errors)
|
||||
else:
|
||||
return py3_stdlib_quote(string, safe=safe, encoding=_encoding, errors=_errors)
|
||||
Loading…
Add table
Add a link
Reference in a new issue