docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class PythonTestUtils

    Implement waiting methods. We leverage the UnityTest attribute for our waits. Contrary to regular C#, we can nest yield return calls and get the "intuitive" behaviour.

    Inheritance
    object
    PythonTestUtils
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEditor.Scripting.Python.Tests
    Assembly: Unity.Scripting.Python.Tests.dll
    Syntax
    public static class PythonTestUtils

    Methods

    WaitForProcessEnd(dynamic, double)

    Returns an IEnumerator to await the end of process. Asserts if the timeout is reached.

    Declaration
    public static IEnumerator WaitForProcessEnd(dynamic process, double timeout = 5)
    Parameters
    Type Name Description
    dynamic process

    The process to wait on. A python popen object

    double timeout

    The maximum length of time for to wait the process to end, in seconds

    Returns
    Type Description
    IEnumerator

    WaitForSecondsDuringUnityTest(double, Func<bool>)

    Because UnityTests can only yield return null (or an IEnumerator yield returning null), we cannot use Unity's WaitForSeconds. Make our own version. If a condition function was given, if the condition never evaluated to True during the loop, raises a Assert.Fail

    Declaration
    public static IEnumerator WaitForSecondsDuringUnityTest(double waitTime, Func<bool> condition = null)
    Parameters
    Type Name Description
    double waitTime

    The interval of time to wait for, in seconds.

    Func<bool> condition

    A function returning a boolean. If the function returns true, exit early.

    Returns
    Type Description
    IEnumerator
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)