fix: cache subject pointer; tidy up tests
Cache the subject pointer in Individual.get_families by calling self.element.get_pointer() once outside the loop to avoid repeated calls and add a clarifying comment. Clean up tests: remove a duplicated TestIndividualBasicInfo fixture/block comment, drop redundant assertions about residence coordinates, and remove an unnecessary return in TestAttributes.
This commit is contained in:
2 files changed
+2
-27
No files matched your search
+2
-1
@@ -211,9 +211,10 @@ class Individual:
|
||||
- children: List of Individual objects
|
||||
"""
|
||||
families = []
|
||||
# Cache the subject pointer once; it doesn't change across families.
|
||||
self_pointer = self.element.get_pointer()
|
||||
for family in self.gedcom.get_families(self.element):
|
||||
# Get partner
|
||||
self_pointer = self.element.get_pointer()
|
||||
partners = [
|
||||
Individual(parent, self.gedcom)
|
||||
for parent in self.gedcom.get_family_members(family, "PARENTS")
|
||||
|
||||
@@ -17,26 +17,6 @@ from gedcom_parser import GedcomParser
|
||||
from individual import Individual
|
||||
|
||||
|
||||
class TestIndividualBasicInfo:
|
||||
"""Tests for basic individual information extraction."""
|
||||
|
||||
@pytest.fixture
|
||||
def john_doe(self, sample_gedcom_file):
|
||||
"""Get the John Doe individual from sample GEDCOM."""
|
||||
parser = GedcomParser(sample_gedcom_file)
|
||||
individuals = parser.get_individuals()
|
||||
"""
|
||||
Tests for the Individual data model.
|
||||
|
||||
This module tests individual person data extraction including:
|
||||
- Names and IDs
|
||||
- Birth and death information
|
||||
- Events and attributes
|
||||
- Family relationships
|
||||
- Images and notes
|
||||
- Custom story tags
|
||||
"""
|
||||
|
||||
class TestIndividualBasicInfo:
|
||||
"""Tests for basic individual information extraction."""
|
||||
|
||||
@@ -350,10 +330,6 @@ class TestEvents:
|
||||
events = person.get_events()
|
||||
event_types = [e['type'] for e in events]
|
||||
|
||||
assert resi['place'] == 'Deepplace'
|
||||
assert resi['lat'] == '48.8566'
|
||||
assert resi['long'] == '2.3522'
|
||||
|
||||
|
||||
class TestFamilyRelationships:
|
||||
"""Tests for family relationship extraction."""
|
||||
@@ -601,8 +577,6 @@ class TestAttributes:
|
||||
attrs = person.get_attributes()
|
||||
assert len(attrs) == 0
|
||||
|
||||
return Individual(john[0], parser.parser)
|
||||
|
||||
def test_get_id(self, john_doe):
|
||||
"""Test ID extraction without @ symbols."""
|
||||
id_value = john_doe.get_id()
|
||||
|
||||
Reference in new issue
Block a user