Skip to content

Commit

Permalink
Merge pull request #395 from joke2k/drop/unicode
Browse files Browse the repository at this point in the history
Removed deprecated Env.unicode()
  • Loading branch information
sergeyklay committed Jun 15, 2022
2 parents bc8860a + 0c7640b commit 1f220bf
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 34 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0
`v0.10.0`_ - 00-Unreleased-2022
-------------------------------

WIP
+++
Removed
+++++++
- Removed deprecated ``Env.unicode()``.


`v0.9.0`_ - 15-June-2022
Expand Down
2 changes: 1 addition & 1 deletion docs/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Features deprecated in 0.9.0
Methods
-------

* The :meth:`.environ.Env.unicode` method is deprecated as it was used
* The ``environ.Env.unicode`` method is deprecated as it was used
for Python 2.x only. Use :meth:`.environ.Env.str` instead.
15 changes: 0 additions & 15 deletions environ/environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,6 @@ def str(self, var, default=NOTSET, multiline=False):
return re.sub(r'(\\r)?\\n', r'\n', value)
return value

def unicode(self, var, default=NOTSET):
"""Helper for python2
:rtype: unicode
"""
warnings.warn(
'`%s.unicode` is deprecated, use `%s.str` instead' % (
self.__class__.__name__,
self.__class__.__name__,
),
DeprecationWarning,
stacklevel=2
)

return self.get_value(var, cast=str, default=default)

def bytes(self, var, default=NOTSET, encoding='utf8'):
"""
:rtype: bytes
Expand Down
16 changes: 0 additions & 16 deletions tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import os
from urllib.parse import quote
from warnings import catch_warnings

import pytest

Expand Down Expand Up @@ -71,21 +70,6 @@ def test_str(self, var, val, multiline):
assert self.env(var) == val
assert self.env.str(var, multiline=multiline) == val

def test_unicode(self, recwarn):
actual = self.env.unicode('CYRILLIC_VAR', default='фуубар')
expected = self.env.str('CYRILLIC_VAR', default='фуубар')

assert actual == expected
assert len(recwarn) == 1
w = recwarn.pop(DeprecationWarning)
assert issubclass(w.category, DeprecationWarning)
assert str(w.message) == '`%s.unicode` is deprecated, use `%s.str` instead' %(
self.env.__class__.__name__,
self.env.__class__.__name__,
)
assert w.filename
assert w.lineno

@pytest.mark.parametrize(
'var,val,default',
[
Expand Down

0 comments on commit 1f220bf

Please sign in to comment.