File: test_417_openssl.py

package info (click to toggle)
python-httpretty 1.1.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 712 kB
  • sloc: python: 4,233; makefile: 72
file content (33 lines) | stat: -rw-r--r-- 1,076 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# This test is based on @ento's example snippet:
# https://gist.github.com/ento/e1e33d7d67e406bf03fe61f018404c21

# Original Issue:
# https://github.com/gabrielfalcao/HTTPretty/issues/417
import httpretty
import requests
import urllib3
from sure import expect
from unittest import skipIf
try:
    from urllib3.contrib.pyopenssl import extract_from_urllib3
except Exception:
    extract_from_urllib3 = None


@skipIf(extract_from_urllib3 is None,
        "urllib3.contrib.pyopenssl.extract_from_urllib3 does not exist")
def test_enable_disable_httpretty_extract():
    "#417 urllib3.contrib.pyopenssl enable -> disable extract"
    expect(urllib3.util.IS_PYOPENSSL).to.be.false
    httpretty.enable()
    httpretty.disable()
    extract_from_urllib3()
    expect(urllib3.util.IS_PYOPENSSL).to.be.false

def test_enable_disable_httpretty():
    "#417 urllib3.contrib.pyopenssl enable -> disable extract"
    expect(urllib3.util.IS_PYOPENSSL).to.be.false
    httpretty.enable()
    httpretty.disable()
    extract_from_urllib3()
    expect(urllib3.util.IS_PYOPENSSL).to.be.false