If you use PythonEngine.ImportModule on a file that contains multiple dots in its name (for example test.one.py), the ImportModule statement will fail and return null.
Embedded UnitTest is sadly lacking at the moment. I'll add pyimport.cs to the EmbeddingTest project with the understanding that this may open a whole new can of worms...
- Barton
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is most likely a red herring: The original post gives a hint that vpiattelli didn't quite have have a handle on python import semantics "(for example test.one.py)"' leaving the extension in place. But it was a great excuse to tear into the UnitTest classes and play around. I've uploaded the results onto the trunk.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Embedded UnitTest is sadly lacking at the moment. I'll add pyimport.cs to the EmbeddingTest project with the understanding that this may open a whole new can of worms...
- Barton
This works against the alpha-2 release:
/// <summary>
/// Test subdirectory import
/// </summary>
/// <remarks>
/// Requires the directory structure to exist where python will find it.
/// (I used
/// site-packages/ to contain the tree:)
/// dotnet/
/// __init__.py
/// test/
/// __init__.py
/// one.py
/// </remarks>
[Test]
public void TestDottedName()
{
PyObject module;
module = PythonEngine.ImportModule("dotnet.test.one");
Assert.IsNotNull(module, ">>> import dotnet.test.one # FAILED");
}
Glad to see this get fixed. Thank you!
This is most likely a red herring: The original post gives a hint that vpiattelli didn't quite have have a handle on python import semantics "(for example test.one.py)"' leaving the extension in place. But it was a great excuse to tear into the UnitTest classes and play around. I've uploaded the results onto the trunk.