Multi-Platform Package Manager for Stable Diffusion
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
using Python.Runtime;
|
|
|
|
using StabilityMatrix.Python;
|
|
|
|
|
|
|
|
namespace StabilityMatrix.Tests.Python;
|
|
|
|
|
|
|
|
[TestClass]
|
|
|
|
public class PyRunnerTests
|
|
|
|
{
|
|
|
|
private static readonly PyRunner PyRunner = new();
|
|
|
|
|
|
|
|
[ClassInitialize]
|
|
|
|
public static async Task TestInitialize(TestContext testContext)
|
|
|
|
{
|
|
|
|
var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
|
|
|
PyRunner.HomeDir = Path.Combine(appData, "StabilityMatrix");
|
|
|
|
await PyRunner.Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
public void PythonEngine_ShouldBeInitialized()
|
|
|
|
{
|
|
|
|
Assert.IsTrue(PythonEngine.IsInitialized);
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
public async Task RunEval_ShouldReturnOutput()
|
|
|
|
{
|
|
|
|
// Arrange
|
|
|
|
const string script = "print('Hello World')";
|
|
|
|
|
|
|
|
// Act
|
|
|
|
var result = await PyRunner.Eval(script);
|
|
|
|
var stdout = PyRunner.StdOutStream!.GetBuffer();
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
Assert.AreEqual("Hello World\n", stdout);
|
|
|
|
Assert.AreEqual("None", result);
|
|
|
|
}
|
|
|
|
}
|