Skip to content

Commit

Permalink
fix ruff errors, move to alpha 6
Browse files Browse the repository at this point in the history
  • Loading branch information
cleder committed Oct 16, 2023
1 parent 954e9dd commit cac607a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 33 deletions.
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ requirements, namely:
* You can parse any KML snippet, it does not need to be a complete KML
document.
* It is fully tested and actively maintained.
* Geometries are handled in the `__geo_interface__` standard.
* Geometries are handled in the ``__geo_interface__`` standard.
* Minimal dependencies, pure Python.
* If available, lxml_ will be used to increase its speed.

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def run_tests(self) -> None:

setup(
name="fastkml",
version="1.0.alpha.5",
version="1.0.alpha.6",
description="Fast KML processing in python",
long_description=(
open("README.rst").read()
Expand Down
46 changes: 23 additions & 23 deletions tests/atom_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ class TestStdLibrary(StdLibrary):

def test_atom_link_ns(self) -> None:
ns = "{http://www.opengis.net/kml/2.2}" # noqa: FS003
l = atom.Link(ns=ns)
assert l.ns == ns
assert l.to_string().startswith(
link = atom.Link(ns=ns)
assert link.ns == ns
assert link.to_string().startswith(
'<kml:link xmlns:kml="http://www.opengis.net/kml/2.2"'
)

def test_atom_link(self) -> None:
l = atom.Link(
link = atom.Link(
href="#here",
rel="alternate",
type="text/html",
Expand All @@ -42,7 +42,7 @@ def test_atom_link(self) -> None:
length=3456,
)

serialized = l.to_string()
serialized = link.to_string()

assert '<atom:link xmlns:atom="http://www.w3.org/2005/Atom"' in serialized
assert 'href="#here"' in serialized
Expand All @@ -53,27 +53,27 @@ def test_atom_link(self) -> None:
assert 'length="3456"' in serialized

def test_atom_link_read(self) -> None:
l = atom.Link()
l.from_string(
link = atom.Link()
link.from_string(
'<atom:link xmlns:atom="http://www.w3.org/2005/Atom" '
'href="#here" rel="alternate" type="text/html" hreflang="en" '
'title="Title" length="3456" />'
)
assert l.href == "#here"
assert l.rel == "alternate"
assert l.type == "text/html"
assert l.hreflang == "en"
assert l.title == "Title"
assert l.length == 3456
assert link.href == "#here"
assert link.rel == "alternate"
assert link.type == "text/html"
assert link.hreflang == "en"
assert link.title == "Title"
assert link.length == 3456

def test_atom_link_read_no_href(self) -> None:
l = atom.Link()
l.from_string(
link = atom.Link()
link.from_string(
'<atom:link xmlns:atom="http://www.w3.org/2005/Atom" '
'rel="alternate" type="text/html" hreflang="en" '
'title="Title" length="3456" />'
)
assert l.href is None
assert link.href is None

def test_atom_person_ns(self) -> None:
ns = "{http://www.opengis.net/kml/2.2}" # noqa: FS003
Expand Down Expand Up @@ -133,14 +133,14 @@ def test_author_roundtrip(self) -> None:
assert a.to_string() == a2.to_string()

def test_link_roundtrip(self) -> None:
l = atom.Link(href="http://localhost/", rel="alternate")
l.title = "Title"
l.type = "text/html"
l.hreflang = "en"
l.length = 4096
link = atom.Link(href="http://localhost/", rel="alternate")
link.title = "Title"
link.type = "text/html"
link.hreflang = "en"
link.length = 4096
l2 = atom.Link()
l2.from_string(l.to_string())
assert l.to_string() == l2.to_string()
l2.from_string(link.to_string())
assert link.to_string() == l2.to_string()


class TestLxml(Lxml, TestStdLibrary):
Expand Down
23 changes: 16 additions & 7 deletions tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def test_to_string(self) -> None:
obj = base._BaseObject(id="id-0", target_id="target-id-0")
obj.__name__ = "test"

assert (
obj.to_string()
== '<kml:test xmlns:kml="http://www.opengis.net/kml/2.2" id="id-0" targetId="target-id-0" />'
assert obj.to_string() == (
'<kml:test xmlns:kml="http://www.opengis.net/kml/2.2" '
'id="id-0" targetId="target-id-0" />'
)

def test_to_str_empty_ns(self) -> None:
Expand All @@ -51,7 +51,10 @@ def test_from_string(self) -> None:
be.__name__ = "test"

be.from_string(
xml_string='<kml:test xmlns:kml="http://www.opengis.net/kml/2.2" id="id-0" targetId="target-id-0" />'
xml_string=(
'<kml:test xmlns:kml="http://www.opengis.net/kml/2.2" '
'id="id-0" targetId="target-id-0" />'
)
)

assert be.id == "id-0"
Expand All @@ -72,7 +75,10 @@ class Test(base._BaseObject):

def test_base_from_element_raises(self) -> None:
be = base._BaseObject()
element = cast(types.Element, config.etree.Element(config.KMLNS + "Base")) # type: ignore[attr-defined]
element = cast(
types.Element,
config.etree.Element(config.KMLNS + "Base"), # type: ignore[attr-defined]
)

with pytest.raises(TypeError):
be.from_element(element=element)
Expand All @@ -82,7 +88,7 @@ def test_base_from_string_raises(self) -> None:

with pytest.raises(TypeError):
be.from_string(
xml_string='<kml:test xmlns:kml="http://www.opengis.net/kml/2.2" id="id-0" />'
'<kml:test xmlns:kml="http://www.opengis.net/kml/2.2" id="id-0" />'
)

def test_base_class_from_string(self) -> None:
Expand Down Expand Up @@ -117,7 +123,10 @@ def test_from_string(self) -> None:
be.__name__ = "test"

be.from_string(
xml_string='<kml:test xmlns:kml="http://www.opengis.net/kml/2.2" id="id-0" targetId="target-id-0"/>\n'
xml_string=(
'<kml:test xmlns:kml="http://www.opengis.net/kml/2.2" '
'id="id-0" targetId="target-id-0"/>\n'
)
)

assert be.id == "id-0"
Expand Down
3 changes: 2 additions & 1 deletion tests/styles_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ def test_style_read(self) -> None:
style = styles.Style()

style.from_string(
'<kml:Style xmlns:kml="http://www.opengis.net/kml/2.2" id="id-0" targetId="target-0">'
'<kml:Style xmlns:kml="http://www.opengis.net/kml/2.2" '
'id="id-0" targetId="target-0">'
'<kml:IconStyle id="id-i0" targetId="target-i0">'
"<kml:color>ff0000ff</kml:color>"
"<kml:colorMode>random</kml:colorMode>"
Expand Down

0 comments on commit cac607a

Please sign in to comment.