Skip to content

Commit

Permalink
Merge pull request #65 from abelcheung/create-pull-request/formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
abelcheung authored Oct 23, 2024
2 parents 85349b6 + 17564e7 commit 398510c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
1 change: 1 addition & 0 deletions test-rt/_testutils/pyright_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def visit_Name(self, node: ast.Name) -> ast.Name:
raise
return node


class _TypeCheckerAdapter(TypeCheckerAdapterBase):
id = "pyright"
typechecker_result = {}
Expand Down
22 changes: 11 additions & 11 deletions test-rt/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,52 +43,52 @@ def bightml_bin_fp() -> _t.Iterator[lzma.LZMAFile]:
# and don't include Iterator/Generator
@pytest.fixture
def bightml_txt_fp() -> _t.Iterator[_t.TextIO]:
fp = lzma.open(_bightml_filepath(), "rt", encoding='utf-8')
fp = lzma.open(_bightml_filepath(), "rt", encoding="utf-8")
yield fp
if not fp.closed:
fp.close()


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def bightml_str() -> str:
with lzma.open(_bightml_filepath(), "rt", encoding='utf-8') as f:
with lzma.open(_bightml_filepath(), "rt", encoding="utf-8") as f:
result = f.read()
return result


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def bightml_bytes() -> bytes:
with lzma.open(_bightml_filepath(), "rb") as f:
result = f.read()
return result


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def html2_filepath() -> Path:
return Path(__file__).resolve().parent / "data" / "mdn-sample.html"


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def html2_fileuri(html2_filepath: Path) -> str:
return "file:///" + str(html2_filepath)


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def html2_str(html2_filepath: Path) -> str:
return html2_filepath.read_text()


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def html2_bytes(html2_filepath: Path) -> bytes:
return html2_filepath.read_bytes()


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def svg_filepath() -> Path:
return Path(__file__).resolve().parent / "data" / "w3c-example.svg"


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def xml2_filepath() -> Path:
return Path(__file__).resolve().parent / "data" / "shiporder.xml"

Expand Down Expand Up @@ -136,7 +136,7 @@ def xml2_root(xml2_tree: _e._ElementTree) -> _e._Element:
return xml2_tree.getroot()


@pytest.fixture(scope='session')
@pytest.fixture(scope="session")
def xinc_sample_data(xml2_filepath: Path) -> str:
inc_href = PurePosixPath(xml2_filepath.resolve().relative_to(Path.cwd()))
return """<doc xmlns:xi="http://www.w3.org/2001/XInclude">
Expand Down
12 changes: 10 additions & 2 deletions test-rt/test_elem_class_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def test_single_ns_all_tag_1(self, svg_filepath: pathlib.Path) -> None:
for all nodes under specific namespace"""
lookup = _e.ElementNamespaceClassLookup()
ns = lookup.get_namespace(self.FOONS)

@ns(None)
class MyBaseElement(ElementBase):
pass
Expand Down Expand Up @@ -87,6 +88,7 @@ def test_single_ns_all_tag_2(
that parser subscript type can't be modified"""
lookup = _e.ElementNamespaceClassLookup()
ns = lookup.get_namespace(self.FOONS)

@ns(None)
class MyBaseElement(ElementBase):
pass
Expand Down Expand Up @@ -122,6 +124,7 @@ class to registry, where tag name equals class name
"""
lookup = _e.ElementNamespaceClassLookup()
ns = lookup.get_namespace(self.FOONS)

@ns
class title(ElementBase): # pyright: ignore[reportUnusedClass]
pass
Expand All @@ -134,7 +137,8 @@ class descr(ElementBase):

class emph(ElementBase):
pass
ns['emph'] = emph

ns["emph"] = emph

parser = XMLParser()
parser.set_element_class_lookup(lookup)
Expand All @@ -155,18 +159,21 @@ class to registry, where tag name and class name
are different"""
lookup = _e.ElementNamespaceClassLookup()
ns = lookup.get_namespace(self.FOONS)

@ns("title")
class _TitleClass(ElementBase): # pyright: ignore[reportUnusedClass]
pass

class _DescClass(ElementBase):
pass

# mypy error: Cannot assign to a type
_DescClass = ns("descr")(_DescClass) # type: ignore[misc]

class _EmphClass(ElementBase):
pass
ns['emph'] = _EmphClass

ns["emph"] = _EmphClass

parser = XMLParser()
parser.set_element_class_lookup(lookup)
Expand All @@ -189,6 +196,7 @@ def test_default_ns(
ElementDefaultClassLookup"""
lookup = _e.ElementNamespaceClassLookup()
ns = lookup.get_namespace(None)

@ns(None)
class MyBaseElement(ElementBase):
pass
Expand Down
4 changes: 3 additions & 1 deletion test-rt/test_html5lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ def test_fs_src(self, html2_str: str, html2_bytes: bytes) -> None:
("fromstring",),
],
)
def test_invalid_src(self, html2_str: str, html2_filepath: Path, funcname: str) -> None:
def test_invalid_src(
self, html2_str: str, html2_filepath: Path, funcname: str
) -> None:
sio = StringIO(html2_str)
fh = open(html2_filepath, "rb")
for src in (None, sio, fh):
Expand Down

0 comments on commit 398510c

Please sign in to comment.