Skip to content
Myr

Merge pull request #4182 from alexwlchan/idna-version

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Add idna version info to requests.help

authored by Nate Prewitt · committed by GitHub · parents 12c7456, d6b57c6 · Browse files · 3 files+26 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+26 added−0 removed

  • tests:+19 added−0 removed
  • other:+7 added−0 removed

3 files+26 added−0 removed

modified:requests/help.py+5 added
4 unmodified lines
5import platform6import sys7import ssl89import idna10import urllib311import chardet1213from . import __version__ as requests_version
70 unmodified lines
84 }85 cryptography_info = {86 'version': getattr(cryptography, '__version__', ''),87 }88 idna_info = {89 'version': getattr(idna, '__version__', ''),90 }9192 # OPENSSL_VERSION_NUMBER doesn't exist in the Python 2.6 ssl module.93 system_ssl = getattr(ssl, 'OPENSSL_VERSION_NUMBER', None)94 system_ssl_info = {
8 unmodified lines
103 'pyOpenSSL': pyopenssl_info,104 'urllib3': urllib3_info,105 'chardet': chardet_info,106 'cryptography': cryptography_info,107 'idna': idna_info,108 'requests': {109 'version': requests_version,110 },111 }
9 unmodified lines
modified:tests/test_help.py+19 added
17 unmodified lines
18@pytest.mark.skipif(sys.version_info < (2,7), reason="Only run on Python 2.7+")19def test_system_ssl():20 """Verify we're actually setting system_ssl when it should be available."""21 assert info()['system_ssl']['version'] != ''222324class VersionedPackage(object):25 def __init__(self, version):26 self.__version__ = version272829def test_idna_without_version_attribute(mocker):30 """Older versions of IDNA don't provide a __version__ attribute, verify31 that if we have such a package, we don't blow up.32 """33 mocker.patch('requests.help.idna', new=None)34 assert info()['idna'] == {'version': ''}353637def test_idna_with_version_attribute(mocker):38 """Verify we're actually setting idna version when it should be available."""39 mocker.patch('requests.help.idna', new=VersionedPackage('2.6'))40 assert info()['idna'] == {'version': '2.6'}
modified:HISTORY.rst+2 added
6 unmodified lines
7+++89**Improvements**1011- Running ``$ python -m requests.help`` now includes the installed version of idna.1213**Bugfixes**14152.18.2 (2017-07-25)16+++++++++++++++++++
1497 unmodified lines