示例#1
0
def test_repr():
    """Test the __repr__ function."""
    blog = Blog("Test", "Test Author")
    blog2 = Blog("My Day", "Fabio")

    assert blog.__repr__() == "Test by Test Author (0 posts)"
    assert blog2.__repr__() == "My Day by Fabio (0 posts)"
示例#2
0
def test_repr_multiple_posts():
    """Test the __repr__ function with multiple posts."""
    blog = Blog("Test", "Test Author")
    blog.posts = ["test"]
    blog2 = Blog("My Day", "Fabio")
    blog2.posts = ["test", "another"]

    assert blog.__repr__() == "Test by Test Author (1 post)"
    assert blog2.__repr__() == "My Day by Fabio (2 posts)"