From 50e69c2055a8641529214af791f96f436821284e Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Sat, 26 Oct 2024 17:27:13 +0100 Subject: [PATCH] remove duplicate test cases --- docs/working_with_kml.rst | 7 +++++-- fastkml/utils.py | 2 +- tests/utils_test.py | 21 --------------------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/docs/working_with_kml.rst b/docs/working_with_kml.rst index a646d5c4..0823dbf8 100644 --- a/docs/working_with_kml.rst +++ b/docs/working_with_kml.rst @@ -16,7 +16,9 @@ Open a KML file: >>> k = KML.parse("docs/Document-clean.kml") -Extract all placemarks and print their geometries: +Extract all placemarks and print their geometries. +The function ``find_all`` recursively searches a KML document for elements of a specific +type and returns an iterator of all matching elements found in the document tree. .. code-block:: pycon @@ -39,7 +41,8 @@ Extract all placemarks and print their geometries: -You can also define what you are looking for by specifying additional parameters: +``find_all`` can also search for arbitrary elements by their attributes, by passing the +attribute name and value as keyword arguments: .. code-block:: pycon diff --git a/fastkml/utils.py b/fastkml/utils.py index 71d879a4..fd963341 100644 --- a/fastkml/utils.py +++ b/fastkml/utils.py @@ -50,7 +50,7 @@ def find_all( ): yield obj try: - attrs = [attr for attr in obj.__dict__ if not attr.startswith("_")] + attrs = (attr for attr in obj.__dict__ if not attr.startswith("_")) except AttributeError: return for attr_name in attrs: diff --git a/tests/utils_test.py b/tests/utils_test.py index efbe07a7..b62bbc39 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -72,27 +72,6 @@ def __init__(self, a: A, b: B, c: C) -> None: result = list(find_all(d1, of_type=A, x=2)) assert not result - result = list(find_all(d1, of_type=A, x=1)) - assert result == [a1] - - result = list(find_all(d1, of_type=A, x=2)) - assert not result - - result = list(find_all(d1, of_type=A, x=1)) - assert result == [a1] - - result = list(find_all(d1, of_type=A, x=2)) - assert not result - - result = list(find_all(d1, of_type=A, x=1)) - assert result == [a1] - - result = list(find_all(d1, of_type=A, x=2)) - assert not result - - result = list(find_all(d1, of_type=A, x=1)) - assert result == [a1] - result = list(find_all(d2, of_type=A, x=2)) assert result == [a2]