コード例 #1
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"
コード例 #2
0
def test_band_str():
    beatles = Band("Beatles")
    actual = beatles.__str__()
    expected = "this is the string inside Band class with instance Beatles"
    assert expected == actual