def recordTest(testName, elapsedTime, metadata, **kwargs):
    if not (isinstance(elapsedTime, float) or elapsedTime is None):
        raise UserWarning(
            "We may only record a float, or None (in case of failure) for elapsed time"
            )

    if not isCurrentlyTesting():
        raise UserWarning(
            "We are not currently testing, so we can't record test results. "
            "Set the environment variable " + TEST_DATA_LOCATION_ENVIRONMENT_VARIABLE +
            " to point to a valid path.")

    targetPath = os.getenv(TEST_DATA_LOCATION_ENVIRONMENT_VARIABLE)
    if metadata is None:
        metadata = {}
    if kwargs is not None:
        metadata.update(kwargs)

    perfLogEntry = {
        "name": str(testName),
        "time": elapsedTime if isinstance(elapsedTime, float) else None,
        "metadata": metadata
        }

    if targetPath == '-':
        print "%2.2f  --  %s" % (elapsedTime, testName)
    else:
        with open(targetPath, "ab+") as f:
            f.write(json.dumps(perfLogEntry) + "\n")
dataset/ETHPy150Open ufora/ufora/ufora/test/PerformanceTestReporter.py/recordTest/original