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.
Inherited Members
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 |