Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Moved the test to Python.
Added EmbeddedPythonTest with the capability to run any desired Python tests within NUnit.
  • Loading branch information
tminka committed Dec 18, 2020
commit 612c0ccdbed557f731669cf24e4124d8de3ed71e
22 changes: 15 additions & 7 deletions src/embed_tests/TestList.cs → src/embed_tests/TestPythonTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
Expand All @@ -8,7 +9,7 @@

namespace Python.EmbeddingTest
{
public class TestList
public class TestPythonTests
{
[OneTimeSetUp]
public void SetUp()
Expand All @@ -22,14 +23,21 @@ public void Dispose()
PythonEngine.Shutdown();
}

[Test]
public void MissingGenericTypeTest()
static IEnumerable<string[]> MyTestCases()
{
Assert.Throws<PythonException>(() =>
yield return new[] { "test_generic", "test_missing_generic_type" };
}

[TestCaseSource(nameof(MyTestCases))]
public void EmbeddedPythonTest(string testFile, string testName)
{
string folder = @"..\\..\\..\\..\\tests";
PythonEngine.Exec($@"
from System.Collections import IList
IList[bool]
"));
import sys
sys.path.insert(0, '{folder}')
from {testFile} import *
{testName}()
");
}
}
}
5 changes: 5 additions & 0 deletions src/tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,3 +745,8 @@ def test_nested_generic_class():
"""Check nested generic classes."""
# TODO NotImplemented
pass

def test_missing_generic_type():
from System.Collections import IList
with pytest.raises(TypeError):
IList[bool]