Пример #1
0
def test_band():
    beatles = Band(
        "The Beatles", ["John Lennon", "Paul McCartney", "George Harrison"],
        ["Sympathy for the Devil", "Light My Fire", "Sharp Dressed Man"])
    assert beatles.name == "The Beatles"
    assert beatles.members == [
        "John Lennon", "Paul McCartney", "George Harrison"
    ]
    assert beatles.__repr__(
    ) == "Band(The Beatles,['John Lennon', 'Paul McCartney', 'George Harrison'],['Sympathy for the Devil', 'Light My Fire', 'Sharp Dressed Man'])"
    assert beatles.to_list() == "The number of Bands created: 1"
Пример #2
0
def test_some_band(some_band):
    assert some_band.name == "The Beatles"
    assert some_band.to_list() == "The number of Bands created: 2"
    assert some_band.__str__(
    ) == "Band name is 'The Beatles'; and members of the Band Are: John Lennon, Paul McCartney, Siva Mani"
    assert some_band.__repr__(
    ) == "Band(The Beatles,[Musician(John Lennon,Guitar), Musician(Paul McCartney,Bass), Musician(Siva Mani,Drums)],['Sympathy for the Devil', 'Light My Fire', 'Sharp Dressed Man'])"
    assert some_band.play_solos(
    ) == "John Lennon please play the solo: Sympathy for the Devil Paul McCartney please play the solo: Light My Fire Siva Mani please play the solo: Sharp Dressed Man"
    class_args = some_band.create_from_data(
        "pythonic_garage_band/assets/band_input.txt")
    from_data = Band(class_args[0], class_args[1], class_args[2])
    assert from_data.name == "The Beatles"
    assert from_data.to_list() == "The number of Bands created: 3"
    assert from_data.__str__(
    ) == "Band name is 'The Beatles'; and members of the Band Are: John Lennon, Paul McCartney, Siva Mani"
    assert from_data.__repr__(
    ) == "Band(The Beatles,[Musician('John Lennon',Guitar), Musician('Paul McCartney',Bass), Musician('Siva Mani',Drums)],['Sympathy for the Devil', 'Light My Fire', 'Sharp Dressed Man'])"
    assert from_data.play_solos(
    ) == "John Lennon please play the solo: Sympathy for the Devil Paul McCartney please play the solo: Light My Fire Siva Mani please play the solo: Sharp Dressed Man"
def test_band_repr():
    beatles = Band("Beatles")
    actual = beatles.__repr__()
    expected = "Beatles instance in Band class using repr"
    assert expected == actual