Skip to content

Commit

Permalink
Tests pass when ssl module is not included in the Python distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
AWhetter committed Sep 2, 2024
1 parent 367cd96 commit 6877c81
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
9 changes: 9 additions & 0 deletions tests/python/pystdlib/stdlib/json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""json is the same name as a stdlib module."""


class JSONDecoder:
"""Do things with json."""

def decode(self, s):
"""Decode a string."""
return s
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""This is a docstring."""

from ssl import SSLContext
from json import JSONDecoder


class MySSLContext(SSLContext):
class MyJSONDecoder(JSONDecoder):
"""This is a class."""

def my_method(self):
Expand Down
9 changes: 0 additions & 9 deletions tests/python/pystdlib/stdlib/ssl.py

This file was deleted.

26 changes: 13 additions & 13 deletions tests/python/test_pyintegration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1252,30 +1252,30 @@ def built(self, builder):
builder("pystdlib")

def test_integration(self, parse):
ssl_file = parse("_build/html/autoapi/ssl/index.html")
json_file = parse("_build/html/autoapi/json/index.html")

ssl_mod = ssl_file.find(id="ssl")
assert "ssl is the same name" in ssl_mod.parent.text
json_mod = json_file.find(id="json")
assert "json is the same name" in json_mod.parent.text

assert ssl_file.find(id="ssl.SSLContext")
wrap_socket = ssl_file.find(id="ssl.SSLContext.wrap_socket")
assert wrap_socket
wrap_docstring = wrap_socket.parent.find("dd").text.strip()
assert wrap_docstring == "Wrap a socket."
assert json_file.find(id="json.JSONDecoder")
decode = json_file.find(id="json.JSONDecoder.decode")
assert decode
wrap_docstring = decode.parent.find("dd").text.strip()
assert wrap_docstring == "Decode a string."

myssl_file = parse("_build/html/autoapi/myssl/index.html")
myjson_file = parse("_build/html/autoapi/myjson/index.html")

# Find members that are not inherited from local standard library classes.
ctx = myssl_file.find(id="myssl.MySSLContext")
ctx = myjson_file.find(id="myjson.MyJSONDecoder")
assert ctx
meth = myssl_file.find(id="myssl.MySSLContext.my_method")
meth = myjson_file.find(id="myjson.MyJSONDecoder.my_method")
assert meth
meth_docstring = meth.parent.find("dd").text.strip()
assert meth_docstring == "This is a method."

# Find members that are inherited from local standard library classes.
wrap_socket = myssl_file.find(id="myssl.MySSLContext.wrap_socket")
assert not wrap_socket
decode = myjson_file.find(id="myjson.MyJSONDecoder.decode")
assert decode

myast_file = parse("_build/html/autoapi/myast/index.html")

Expand Down

0 comments on commit 6877c81

Please sign in to comment.