def test_attack_generate(attack, random_image, accurate_class, not_close, art_warning):
    """
    Test attacking neural network and generating adversarial images.
    """
    try:
        adv_image = attack.generate(np.expand_dims(random_image, 0), np.array([accurate_class]))[0]

        assert adv_image.shape == random_image.shape, "Image shapes are not the same"
        np.testing.assert_array_compare(not_close, random_image, adv_image)
    except ARTTestException as _e:
        art_warning(_e)

    Test attacking neural network and generating adversarial images.
    
tests/attacks/evasion/test_laser_attack.py