test_config.py
This file
Path
tests/test_config.py
173 lines · 5.1 KiB · Python
Last changed by
Raise TypeError if invalid parameter for HTTPVersionConfig (#253)Can Sarıgölbefore adoption4ea4af6
History of this fileTake it
The walk stopped after 200 commits: lines older than bb3d452 point at it.
Finessing interfaceTom Christiebefore adoptiond7619a9
lines 1–4why, one step back1import ssl23import pytest4Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 5why, one step back5import httpxFinessing interfaceTom Christiebefore adoptiond7619a9
lines 6–7why, one step back67Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 8why, one step back8def test_load_ssl_config():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 9why, one step back9 ssl_config = httpx.SSLConfig()Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 10why, one step back10 context = ssl_config.load_ssl_context()Finessing interfaceTom Christiebefore adoptiond7619a9
line 11why, one step back11 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIREDSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 12why, one step back12 assert context.check_hostname is TrueMerge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 13–14why, one step back1314Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 15why, one step back15def test_load_ssl_config_verify_non_existing_path():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 16why, one step back16 ssl_config = httpx.SSLConfig(verify="/path/to/nowhere")Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
line 17why, one step back17 with pytest.raises(IOError):Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 18why, one step back18 ssl_config.load_ssl_context()Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 19–20why, one step back1920Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 21why, one step back21def test_load_ssl_config_verify_existing_file():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 22why, one step back22 ssl_config = httpx.SSLConfig(verify=httpx.config.DEFAULT_CA_BUNDLE_PATH)Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 23why, one step back23 context = ssl_config.load_ssl_context()Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
line 24why, one step back24 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIREDSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 25why, one step back25 assert context.check_hostname is TrueMerge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 26–27why, one step back2627Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 28why, one step back28def test_load_ssl_config_verify_directory():Use pathlib.Path instead of os.path functions (#188)Stephen Brown IIbefore adoptionfde30b8
line 29why, one step back29 path = httpx.config.DEFAULT_CA_BUNDLE_PATH.parentRenaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 30why, one step back30 ssl_config = httpx.SSLConfig(verify=path)Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 31why, one step back31 context = ssl_config.load_ssl_context()Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
line 32why, one step back32 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIREDSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 33why, one step back33 assert context.check_hostname is TrueMerge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 34–35why, one step back3435Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 36why, one step back36def test_load_ssl_config_cert_and_key(cert_pem_file, cert_private_key_file):Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 37why, one step back37 ssl_config = httpx.SSLConfig(cert=(cert_pem_file, cert_private_key_file))Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 38why, one step back38 context = ssl_config.load_ssl_context()Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
line 39why, one step back39 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIREDSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 40why, one step back40 assert context.check_hostname is TrueMerge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 41–42why, one step back4142Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 43why, one step back43@pytest.mark.parametrize("password", [b"password", "password"])Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 44why, one step back44def test_load_ssl_config_cert_and_encrypted_key(Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
lines 45–46why, one step back45 cert_pem_file, cert_encrypted_private_key_file, password46):Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 47why, one step back47 ssl_config = httpx.SSLConfig(Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
lines 48–49why, one step back48 cert=(cert_pem_file, cert_encrypted_private_key_file, password)49 )Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 50why, one step back50 context = ssl_config.load_ssl_context()Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
lines 51–54why, one step back51 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED52 assert context.check_hostname is True5354Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 55why, one step back55def test_load_ssl_config_cert_and_key_invalid_password(Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
lines 56–57why, one step back56 cert_pem_file, cert_encrypted_private_key_file57):Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 58why, one step back58 ssl_config = httpx.SSLConfig(Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
lines 59–61why, one step back59 cert=(cert_pem_file, cert_encrypted_private_key_file, "password1")60 )61Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
line 62why, one step back62 with pytest.raises(ssl.SSLError):Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 63why, one step back63 ssl_config.load_ssl_context()Finessing interfaceTom Christiebefore adoptiond7619a9
lines 64–65why, one step back6465Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 66why, one step back66def test_load_ssl_config_cert_without_key_raises(cert_pem_file):Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 67why, one step back67 ssl_config = httpx.SSLConfig(cert=cert_pem_file)Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 68why, one step back68 with pytest.raises(ssl.SSLError):Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 69why, one step back69 ssl_config.load_ssl_context()Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
lines 70–71why, one step back7071Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 72why, one step back72def test_load_ssl_config_no_verify():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 73why, one step back73 ssl_config = httpx.SSLConfig(verify=False)Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6
line 74why, one step back74 context = ssl_config.load_ssl_context()Finessing interfaceTom Christiebefore adoptiond7619a9
line 75why, one step back75 assert context.verify_mode == ssl.VerifyMode.CERT_NONESupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 76why, one step back76 assert context.check_hostname is FalseUpdate README for 0.2.0Tom Christiebefore adoptionbb3d452
lines 77–78why, one step back7778Accept SSLContext into SSLConfig(verify=...) (#215)Seth Michael Larsonbefore adoptiondf8874b
lines 79–87why, one step back79def test_load_ssl_context():80 ssl_context = ssl.create_default_context()81 ssl_config = httpx.SSLConfig(verify=ssl_context)8283 assert ssl_config.verify is True84 assert ssl_config.ssl_context is ssl_context85 assert repr(ssl_config) == "SSLConfig(cert=None, verify=True)"8687Update README for 0.2.0Tom Christiebefore adoptionbb3d452
line 88why, one step back88def test_ssl_repr():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 89why, one step back89 ssl = httpx.SSLConfig(verify=False)Update README for 0.2.0Tom Christiebefore adoptionbb3d452
lines 90–92why, one step back90 assert repr(ssl) == "SSLConfig(cert=None, verify=False)"9192Merge pull request #241 from encode/protocol-supportTom Christiebefore adoptione0b523d
lines 93–117why, one step back93def test_http_versions_repr():94 http_versions = httpx.HTTPVersionConfig()95 assert repr(http_versions) == "HTTPVersionConfig(['HTTP/1.1', 'HTTP/2'])"969798def test_http_versions_from_string():99 http_versions = httpx.HTTPVersionConfig("HTTP/1.1")100 assert repr(http_versions) == "HTTPVersionConfig(['HTTP/1.1'])"101102103def test_http_versions_from_list():104 http_versions = httpx.HTTPVersionConfig(["http/1.1"])105 assert repr(http_versions) == "HTTPVersionConfig(['HTTP/1.1'])"106107108def test_http_versions_from_config():109 http_versions = httpx.HTTPVersionConfig(httpx.HTTPVersionConfig("HTTP/1.1"))110 assert repr(http_versions) == "HTTPVersionConfig(['HTTP/1.1'])"111112113def test_invalid_http_version():114 with pytest.raises(ValueError):115 httpx.HTTPVersionConfig("HTTP/9")116117Raise TypeError if invalid parameter for HTTPVersionConfig (#253)Can Sarıgölbefore adoption4ea4af6
lines 118–127why, one step back118def test_invalid_http_version_type():119 with pytest.raises(TypeError):120 httpx.HTTPVersionConfig(123)121122123def test_invalid_http_version_list_type():124 with pytest.raises(ValueError):125 httpx.HTTPVersionConfig([123])126127Merge pull request #241 from encode/protocol-supportTom Christiebefore adoptione0b523d
lines 128–132why, one step back128def test_empty_http_version():129 with pytest.raises(ValueError):130 httpx.HTTPVersionConfig([])131132Update README for 0.2.0Tom Christiebefore adoptionbb3d452
line 133why, one step back133def test_timeout_repr():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 134why, one step back134 timeout = httpx.TimeoutConfig(timeout=5.0)Update README for 0.2.0Tom Christiebefore adoptionbb3d452
lines 135–136why, one step back135 assert repr(timeout) == "TimeoutConfig(timeout=5.0)"136Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 137why, one step back137 timeout = httpx.TimeoutConfig(read_timeout=5.0)Update README for 0.2.0Tom Christiebefore adoptionbb3d452
lines 138–139why, one step back138 assert (139 repr(timeout)Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 140why, one step back140 == "TimeoutConfig(connect_timeout=None, read_timeout=5.0, write_timeout=None)"Update README for 0.2.0Tom Christiebefore adoptionbb3d452
lines 141–144why, one step back141 )142143144def test_limits_repr():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 145why, one step back145 limits = httpx.PoolLimits(hard_limit=100)Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 146–148why, one step back146 assert (147 repr(limits) == "PoolLimits(soft_limit=None, hard_limit=100, pool_timeout=None)"148 )Update README for 0.2.0Tom Christiebefore adoptionbb3d452
lines 149–151why, one step back149150151def test_ssl_eq():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 152–153why, one step back152 ssl = httpx.SSLConfig(verify=False)153 assert ssl == httpx.SSLConfig(verify=False)Update README for 0.2.0Tom Christiebefore adoptionbb3d452
lines 154–156why, one step back154155156def test_timeout_eq():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 157–158why, one step back157 timeout = httpx.TimeoutConfig(timeout=5.0)158 assert timeout == httpx.TimeoutConfig(timeout=5.0)Update README for 0.2.0Tom Christiebefore adoptionbb3d452
lines 159–161why, one step back159160161def test_limits_eq():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 162–163why, one step back162 limits = httpx.PoolLimits(hard_limit=100)163 assert limits == httpx.PoolLimits(hard_limit=100)Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 164–166why, one step back164165166def test_timeout_from_tuple():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 167–168why, one step back167 timeout = httpx.TimeoutConfig(timeout=(5.0, 5.0, 5.0))168 assert timeout == httpx.TimeoutConfig(timeout=5.0)Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 169–171why, one step back169170171def test_timeout_from_config_instance():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 172–173why, one step back172 timeout = httpx.TimeoutConfig(timeout=5.0)173 assert httpx.TimeoutConfig(timeout) == httpx.TimeoutConfig(timeout=5.0)