-
Notifications
You must be signed in to change notification settings - Fork 747
Python tests can now be debugged by running them as embedded tests within NUnit #1341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
These must not be run during CI. As I suggested, this should be a separate project file. |
Why can't they run during CI? They do test the embedding system. Also, it is important that this setup is not broken by some other change. |
That makes sense. But still I would put them into a separate project file. |
bbb7a0c
to
75c49fe
Compare
It appears that |
@tminka I think the cause might be that the OS image running actions in CI has Python 3.8 installed as system Python, and when embed tests are running, it is being picked up instead of the one in custom environment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, just noticed the issue with skipped Shutdown
@lostmsu I don't think it is picking up the wrong Python installation because an earlier commit showed the value of sys.path in the embedded tests:
The "Install dependencies" step installed pytest into |
@tminka since you moved python test running from .NET to a separate project and CI step, you no longer need the changes to |
I agree, but I think the change to importhook is important enough (and harmless enough) to keep in this PR. |
src/runtime/importhook.cs
Outdated
@@ -342,7 +345,7 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw) | |||
ManagedType mt = tail.GetAttribute(name, true); | |||
if (!(mt is ModuleObject)) | |||
{ | |||
Exceptions.SetError(Exceptions.ImportError, $"No module named {name}"); | |||
Exceptions.SetError(Exceptions.ImportError, originalExceptionMessage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use PythonException.Restore()
…thin NUnit. Added PythonTestsRunner project and extra build actions.
What does this implement/fix? Explain your changes.
When debugging a problem such as issue #1325, it is immensely useful to have the Visual Studio debugger stop at the location of the error. This is tricky to do with pytest, even when running pytest from Visual Studio. Running the test via Python.Exec makes debugging simple and easy. You don't need to re-install Python.NET every time you make a change. You don't need to edit project options, and you don't need to figure out how to run pytest from Visual Studio.
With this change, you can just type in the name of the python test you want to debug, build the solution, and debug the new NUnit test that appears.
Does this close any currently open issues?
No
Any other comments?
No
Checklist
Check all those that are applicable and complete.
AUTHORS
CHANGELOG