from pathlib import Path
import random


def get_random_test(tests_path):
    """
    returns a random .png file from given trajectory

    args:
        tests_path (path-like): directory of test files

    returns:
        sample_path (path-like): direct path to one .png

    errors:
        IndexError if no .png files are in tests_path
    """
    tests = [e for e in Path(tests_path).glob("*.png")]
    sample_path = random.sample(tests,1)[0]
    return sample_path