Python handling of C# collection
Environment
- Pythonnet version: master/3.0
- Python version: *
- Operating System: *
- .NET Runtime: *
Details
- Describe what you were trying to get done.
Seems that since CollectionMixinsProvider was added this case started failing (if key in collection.Keys:), not sure why CollectionMixinsProvider is required, if this is a bug or not..
Test passes commenting out https://github.com/pythonnet/pythonnet/blob/master/src/runtime/InteropConfiguration.cs#L24
- What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
class ATests { private static dynamic containsTest; private static string testModule = @" from clr import AddReference AddReference(""System"") AddReference(""Python.EmbeddingTest"") def ContainsTest(key, collection): if key in collection.Keys: return True return False "; [OneTimeSetUp] public void Setup() { PythonEngine.Initialize(); var pyModule = PyModule.FromString("module", testModule); containsTest = pyModule.GetAttr("ContainsTest"); } [TestCase("AAPL", false)] [TestCase("SPY", true)] public void ContainsTest(string key, bool expected) { var dic = new Dictionary<string, object> { { "SPY", new object() } }; Assert.AreEqual(expected, (bool)containsTest(key, dic)); } }