Skip to content

Commit 8a78d46

Browse files
author
Bogdan Hodorog
committed
Add six as dependency. Support older six-es as well.
1 parent 1ecca37 commit 8a78d46

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
This project uses [Semantic Versioning][] and follows [these][keepachangelog] changelog guidelines.
22

3+
# v0.4.7 - 2019-06-28
4+
#### Fixed:
5+
- ensure six is a newer version
6+
37
# v0.4.6 - 2019-06-27
48
#### Fixed:
59

@@ -12,7 +16,7 @@ This project uses [Semantic Versioning][] and follows [these][keepachangelog] ch
1216
- should fix using `requests.post(url, json=dict(...))`
1317

1418
# v0.4.5 - 2018-06-18
15-
####Fixed:
19+
#### Fixed:
1620
- custom wrappers now work properly in playback mode
1721

1822
# v0.4.4 - 2018-05-15

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ pypi-sdist-wheel: test pypi-sdist-clean
88
python setup.py egg_info sdist
99
tox -e wheel
1010

11-
pypi-upload: pypi-sdist-wheel
11+
pypi-upload:
1212
$(eval TAG := "v"$(shell python setup.py --version))
1313
tox -e twine -- upload --username bhodorog dist/*
1414
git -c 'user.name=Bogdan Hodorog' -c '[email protected]' tag -a -m "Manually built using make" $(TAG)
1515
git push origin $(TAG)
1616

17-
.PHONY: test
17+
release: pypi-sdist-wheel pypi-upload
18+
19+
.PHONY: test release
1820
.PHONY: pypi-sdist-clean pypi-sdist pypi-upload

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
version=__version__, # noqa
1414
packages=find_packages("src"),
1515
package_dir={"": "src"},
16-
install_requires=["pytest >=2.3", "responses", "cookies"],
16+
install_requires=["pytest >=2.3", "responses", "cookies", "six"],
1717
entry_points={
1818
"pytest11": [
1919
"pytest_vts = pytest_vts"

src/pytest_vts/logic/machine.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,32 @@ class RequestBodyDoesntMatchTrack(Exception):
2323
pass
2424

2525

26-
def ensure_text_silent(s, *args, **kwargs):
27-
if s is None:
28-
return s
29-
return six.ensure_text(s, *args, **kwargs)
26+
def ensure_text_silent(ss, *args, **kwargs):
27+
if ss is None:
28+
return ss
29+
if hasattr(six, "ensure_text"):
30+
_ensure_text = six.ensure_text
31+
else:
32+
def _ensure_text(s, encoding='utf-8', errors='strict'):
33+
"""Coerce *s* to six.text_type.
34+
For Python 2:
35+
- `unicode` -> `unicode`
36+
- `str` -> `unicode`
37+
For Python 3:
38+
- `str` -> `str`
39+
- `bytes` -> decoded to `str`
40+
41+
"Stolen" from six >1.12.0 to avoid having a hard dependency on that,
42+
but rather allow clients to use any version of six
43+
"""
44+
if isinstance(s, six.binary_type):
45+
return s.decode(encoding, errors)
46+
elif isinstance(s, six.text_type):
47+
return s
48+
else:
49+
raise TypeError("not expecting type '%s'" % type(s))
50+
return _ensure_text(ss, *args, **kwargs)
51+
3052

3153
def function_name(pytest_req):
3254
return pytest_req.node.name

0 commit comments

Comments
 (0)