def test_sex_female(): p = Person("female") assert p.sex == "female" global spy_job_was_called spy_job_was_called = False p.do_job_based_on_sex(dummy_job, spy_job) assert spy_job_was_called
def cast_to_persons(list_of_names) -> set: persons = set() for name in list_of_names: if name in women_names: persons.add(Person("female", name)) else: persons.add(Person("male", name)) return persons
def test_incorrect_R_relations(dummy): impossible_father_in_law = Person(sex="female") assert not impossible_father_in_law.can_be_father_in_law_of(dummy) father_in_law = Person(sex="male") impossible_son_in_law = Person(sex="female") assert not father_in_law.can_be_father_in_law_of(impossible_son_in_law) assert not father_in_law.can_be_father_in_law_of(father_in_law)
def index_person_advanced(person: Person, out_cached_index): if person is None: raise ValueError() if person.name in out_cached_index: return out_cached_index.index(person.name) + 1 else: out_cached_index.append(person.name) person.id = len(out_cached_index) return person.id
def test_correct_R_relations(): father_in_law = Person(sex="male") son_in_law = Person(sex="male") assert father_in_law.can_be_father_in_law_of(son_in_law)
def left_handed(): return Person("male")
def test_sex_male(): p = Person("male") assert p.sex == "male" p.do_job_based_on_sex(spy_job, dummy_job) assert spy_job_was_called == True
def female3(): return Person("female", "Female3")
def righhanders(): return {Person("male"), Person("female"), Person("male"), Person("male")}
def female1(): return Person("female", "Female1")
def female2(): return Person("female", "Female2")
def female(): return Person("female", "Female")
def male3(): return Person("male", "Male3")
def male2(): return Person("male", "Male2")
def male1(): return Person("male", "Male1")
def male(): return Person("male", "Male")