Skip to content

Commit 4b70ddc

Browse files
committed
Moved the test to Python.
Added EmbeddedPythonTest with the capability to run any desired Python tests within NUnit.
1 parent 07274c6 commit 4b70ddc

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
34
using System.Linq;
45
using System.Reflection;
56
using System.Text;
@@ -8,7 +9,7 @@
89

910
namespace Python.EmbeddingTest
1011
{
11-
public class TestList
12+
public class TestPythonTests
1213
{
1314
[OneTimeSetUp]
1415
public void SetUp()
@@ -22,14 +23,21 @@ public void Dispose()
2223
PythonEngine.Shutdown();
2324
}
2425

25-
[Test]
26-
public void MissingGenericTypeTest()
26+
static IEnumerable<string[]> MyTestCases()
2727
{
28-
Assert.Throws<PythonException>(() =>
28+
yield return new[] { "test_generic", "test_missing_generic_type" };
29+
}
30+
31+
[TestCaseSource(nameof(MyTestCases))]
32+
public void EmbeddedPythonTest(string testFile, string testName)
33+
{
34+
string folder = @"..\\..\\..\\..\\tests";
2935
PythonEngine.Exec($@"
30-
from System.Collections import IList
31-
IList[bool]
32-
"));
36+
import sys
37+
sys.path.insert(0, '{folder}')
38+
from {testFile} import *
39+
{testName}()
40+
");
3341
}
3442
}
3543
}

src/tests/test_generic.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,3 +745,8 @@ def test_nested_generic_class():
745745
"""Check nested generic classes."""
746746
# TODO NotImplemented
747747
pass
748+
749+
def test_missing_generic_type():
750+
from System.Collections import IList
751+
with pytest.raises(TypeError):
752+
IList[bool]

0 commit comments

Comments
 (0)