Пример #1
0
def one_band():
    some_band = Band(
        "Nirvana",
        [
            Guitarist("Kurt Cobain"),
            Bassist("Krist Novoselic"),
            Drummer("Dave Grohl"),
        ],
    )
    return some_band
Пример #2
0
def test_from_file():
    with open("assets/bands.json") as f:
        bands = json.loads(f.read())

    assert len(bands) == 1

    nirvana_data = bands[0]

    nirvana = Band(nirvana_data["name"], nirvana_data["members"])

    assert nirvana.name == "Nirvana"
Пример #3
0
def test_band_name():
    nirvana = Band("Nirvana", [])

    assert nirvana.name == "Nirvana"
Пример #4
0
def test_band_repr():
    nirvana = Band("Nirvana", [])
    actual = repr(nirvana)
    expected = "Band instance. name=Nirvana, members=[]"
    assert actual == expected
Пример #5
0
def test_to_list():
    assert Band.to_list() == []
    Band("The Nobodies", [])
    assert len(Band.to_list()) == 1
Пример #6
0
def test_band_str():
    nirvana = Band("Nirvana", [])
    actual = str(nirvana)
    expected = "The band Nirvana"
    assert actual == expected
Пример #7
0
def test_to_list():
    assert Band.to_list() == []
    the_nobodies = Band("The Nobodies", [])
    all_bands = Band.to_list()
    assert len(all_bands) == 1
    assert all_bands[0] == the_nobodies
Пример #8
0
def test_class_tracks_instances():
    assert Band.to_list() == []
    the_nobodies = Band("The Nobodies", [])
    assert len(Band.instances) == 1
    assert Band.instances[0] == the_nobodies
Пример #9
0
def test_BandName():
    actual = Band("radiohead").name
    expected = "radiohead"
    assert expected == actual