Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions checks/oop_advanced/oop_advanced1.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dog = Dog()
assert isinstance(dog, Animal)
assert dog.speak() == "sound"
assert isinstance(dog, Animal), "Dog() should be an instance of Animal"
got = dog.speak()
assert got == "sound", f"Dog().speak() should return 'sound', got {got!r}"
print("oop_advanced1 ok")
6 changes: 4 additions & 2 deletions checks/oop_advanced/oop_advanced2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
employee = Employee("Ada", "Engineer")
assert employee.name == "Ada"
assert employee.role == "Engineer"
assert employee.name == "Ada", f"expected name 'Ada', got {employee.name!r}"
assert employee.role == "Engineer", (
f"expected role 'Engineer', got {employee.role!r}"
)
print("oop_advanced2 ok")
3 changes: 2 additions & 1 deletion checks/oop_advanced/oop_advanced3.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
shapes = [Square(3), Rectangle(2, 5)]
assert total_area(shapes) == 19
area = total_area(shapes)
assert area == 19, f"expected total_area(shapes) == 19, got {area!r}"
print("oop_advanced3 ok")
2 changes: 1 addition & 1 deletion checks/oop_advanced/oop_advanced4.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
user = User("Lin")
assert user.name == "Lin"
assert user.name == "Lin", f"expected name 'Lin', got {user.name!r}"
print("oop_advanced4 ok")
3 changes: 2 additions & 1 deletion checks/oop_advanced/oop_advanced5.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
playlist = Playlist(["one", "two", "three"])
assert len(playlist) == 3
count = len(playlist)
assert count == 3, f"expected len(playlist) == 3, got {count!r}"
print("oop_advanced5 ok")
5 changes: 4 additions & 1 deletion checks/oop_advanced/oop_advanced6.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
assert repr(Point(2, 5)) == "Point(x=2, y=5)"
text = repr(Point(2, 5))
assert text == "Point(x=2, y=5)", (
f"expected repr 'Point(x=2, y=5)', got {text!r}"
)
print("oop_advanced6 ok")
Loading