def test_body_part_02(self): self.assertEqual(test_traits('head, thorax, abdomen'), [{ 'body_part': 'head, thorax, abdomen', 'trait': 'body_part', 'start': 0, 'end': 21 }])
def test_antenna_02(self): self.assertEqual( test_traits(""" Antennae five-segmented with basal segment wider than long and much larger than second segment; fourth segment slightly extended posterolaterally. """), [{ 'body_part': 'antenna five-segmented', 'trait': 'body_part', 'start': 0, 'end': 23 }, { 'body_part': 'basal segment', 'trait': 'body_part', 'start': 29, 'end': 42 }, { 'body_part': 'second segment', 'trait': 'body_part', 'start': 80, 'end': 94 }, { 'body_part': 'fourth segment', 'trait': 'body_part', 'start': 96, 'end': 110, 'description': 'slightly extended posterolaterally' }])
def test_body_part_01(self): self.assertEqual(test_traits('fourth segment'), [{ 'body_part': 'fourth segment', 'trait': 'body_part', 'start': 0, 'end': 14 }])
def test_body_part_03(self): self.assertEqual(test_traits('missing eyes'), [{ 'body_part': 'missing eye', 'missing': True, 'trait': 'body_part', 'start': 0, 'end': 12 }])
def test_sci_name_02(self): self.assertEqual(test_traits('four known species of Abrocomaphthirus'), [{ 'genus': 'Abrocomaphthirus', 'group': 'anoplura', 'trait': 'genus', 'start': 22, 'end': 38 }])
def test_description_04(self): self.assertEqual(test_traits("""Stuff on head but not on top."""), [{ 'body_part': 'head', 'trait': 'body_part', 'start': 9, 'end': 13, 'description': ['stuff on', 'but not on top'] }])
def test_antenna_05(self): self.assertEqual(test_traits('Antennal segments 3-5 not fused;'), [{ 'body_part': 'antenna segment 3-5', 'trait': 'body_part', 'start': 0, 'end': 21, 'description': 'not fused' }])
def test_description_03(self): self.assertEqual(test_traits("""Stuff on head."""), [{ 'body_part': 'head', 'trait': 'body_part', 'start': 9, 'end': 13, 'description': 'stuff on' }])
def test_setae_count_03(self): self.assertEqual(test_traits('with pair of long setae'), [{ 'body_part': 'seta', 'present': True, 'seta': 'setae', 'group': 'pair of', 'trait': 'seta_count', 'start': 5, 'end': 23 }])
def test_setae_count_02(self): self.assertEqual(test_traits('no Dorsal Mesothoracic Setae (DMsS);'), [{ 'count': 0, 'seta': 'dorsal mesothoracic setae', 'body_part': 'seta', 'trait': 'seta_count', 'start': 0, 'end': 35 }])
def test_setae_count_01(self): self.assertEqual( test_traits('One long Dorsal Principal Head Seta (DPHS)'), [{ 'count': 1, 'body_part': 'seta', 'seta': 'dorsal principal head seta', 'trait': 'seta_count', 'start': 0, 'end': 42 }])
def test_setae_count_05(self): self.assertEqual( test_traits('One long and one tiny seta immediately posterior to'), [{ 'seta': 'seta', 'count': 2, 'body_part': 'seta', 'trait': 'seta_count', 'start': 0, 'end': 26 }])
def test_antenna_04(self): self.assertEqual( test_traits(""" third antennal segment modified with anterodorsal projection. """), [{ 'body_part': 'third antenna segment', 'trait': 'body_part', 'start': 0, 'end': 22, 'description': 'modified with anterodorsal projection' }])
def test_setae_count_04(self): self.assertEqual( test_traits('with 16–18 contiguous curved setae on each side;'), [{ 'low': 16, 'high': 18, 'seta': 'setae', 'group': 'each side', 'body_part': 'seta', 'trait': 'seta_count', 'start': 5, 'end': 47 }])
def test_sci_name_01(self): self.assertEqual(test_traits('females of L. CLAYTONI sp. nov., .'), [{ 'sex': 'female', 'trait': 'sex', 'start': 0, 'end': 7 }, { 'sci_name': 'L. claytoni', 'group': 'anoplura', 'trait': 'sci_name', 'start': 11, 'end': 22 }])
def test_length_02(self): self.assertEqual( test_traits( 'Maximum thorax width, 0.193–0.228 mm (mean, 0.210, n = 4).'), [{ 'body_part': 'thorax', 'n': 4, 'mean': 0.21, 'low': 0.193, 'high': 0.228, 'length_units': 'mm', 'trait': 'max_width', 'start': 0, 'end': 57 }])
def test_length_01(self): self.assertEqual( test_traits( 'Total body length: 0.99–1.16 mm; mean, 1.09 mm (n = 4).'), [{ 'n': 4, 'mean': 1.09, 'mean_units': 'mm', 'body_part': 'body', 'low': 0.99, 'high': 1.16, 'length_units': 'mm', 'trait': 'total_length', 'start': 0, 'end': 54 }])
def test_max_width_01(self): self.assertEqual( test_traits( 'Maximum head width, 0.150–0.163 mm (mean, 0.17 mm, n = 4).'), [{ 'n': 4, 'mean': 0.17, 'mean_units': 'mm', 'low': 0.150, 'high': 0.163, 'length_units': 'mm', 'body_part': 'head', 'trait': 'max_width', 'start': 0, 'end': 57 }])
def test_description_02(self): self.assertEqual( test_traits(""" Thorax slightly wider and elongate. Thoracic sternal plate extended anteriorly. """), [{ 'body_part': 'thorax', 'trait': 'body_part', 'start': 0, 'end': 6, 'description': 'slightly wider and elongate' }, { 'body_part': 'thoracic sternal plate', 'trait': 'body_part', 'start': 36, 'end': 58, 'description': 'extended anteriorly' }])
def test_length_02(self): self.assertEqual( test_traits(""" DPTS length 0.137 mm (n = 1) (only one unbroken DPTS present). """), [{ 'n': 1, 'low': 0.137, 'length_units': 'mm', 'seta_abbrev': 'dorsal principal thoracic seta', 'trait': 'length', 'start': 0, 'end': 28 }, { 'end': 52, 'start': 48, 'trait': 'seta_abbrev', 'seta_abbrev': 'dorsal principal thoracic seta' }])
def test_sternal_plate_01(self): self.assertEqual( test_traits(""" Thoracic sternal plate subrectangular, about 3⫻ as wide as long; thorax rounded."""), [{ 'body_part': 'thoracic sternal plate', 'trait': 'body_part', 'start': 0, 'end': 22, 'description': 'subrectangular, about 3× as wide as long' }, { 'body_part': 'thorax', 'trait': 'body_part', 'start': 65, 'end': 71, 'description': 'rounded' }])
def test_antenna_01(self): actual = test_traits('Head suboval; antennae unmodified in males;.') self.assertEqual(actual, [{ 'body_part': 'head', 'trait': 'body_part', 'start': 0, 'end': 4, 'description': 'suboval' }, { 'body_part': 'antenna', 'trait': 'body_part', 'start': 14, 'end': 22, 'description': 'unmodified in males' }, { 'sex': 'male', 'trait': 'sex', 'start': 37, 'end': 42 }])
def test_antenna_03(self): self.assertEqual( test_traits(""" Head lacking eyes, with 5-segmented antennae which are often sexually dimorphic. """), [{ 'body_part': 'head', 'trait': 'body_part', 'start': 0, 'end': 4 }, { 'body_part': 'lacking eye', 'missing': True, 'trait': 'body_part', 'start': 5, 'end': 17 }, { 'body_part': '5-segmented antenna', 'trait': 'body_part', 'start': 24, 'end': 44, 'description': 'which are often sexually dimorphic' }])
def test_description_01(self): self.assertEqual( test_traits(""" Head: More heavily sclerotized along anterior margin; longer than broad with squarish, slightly convex anterior margin. """), [{ 'body_part': 'head', 'trait': 'body_part', 'start': 0, 'end': 4 }, { 'body_part': 'anterior margin', 'trait': 'body_part', 'start': 37, 'end': 52 }, { 'body_part': 'anterior margin', 'trait': 'body_part', 'start': 103, 'end': 118, 'description': 'longer than broad with squarish, slightly convex' }])