-
Notifications
You must be signed in to change notification settings - Fork 749
Add support for running pytest from dotnet core 2.0 (dotnet <path>/netcoreapp2.0/nPython.dll) #590
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
Comments
Bad news: I tried to add this support and found too many big and small problems. I will publish my current work state in a new branch little bit later. |
Thanks for this @dmitriyse - sorry for raising so many issues. |
@Cronan thank you for a lot of testing efforts. You issues and reports are very useful. Probably I will reopen some of them later for separate problem solving. |
Hi @dmitriyse , where are you with this? Is there anything I can do? |
Hi @Cronan, unfortunately I am busy now. I forgot to publish my current progress on this issue. I will create branch today. |
The pytests core 2.0 fixes branch has been created. https://github.com/pythonnet/pythonnet/tree/pytests-core |
I'll take a look today, thanks @dmitriyse |
@dmitriyse definitely looking better, gets a lot further. It fails a few tests, mainly due to missing classes in .Net core like System.Drawing, Hashtable, a few others, but crashes hard when it gets to here: _____________________________ test_sys_argv_state ______________________________
filepath = <function make_filepath at 0x2226410>
def test_sys_argv_state(filepath):
"""Test sys.argv state doesn't change after clr import.
To better control the arguments being passed, test on a fresh python
instance with specific arguments"""
script = filepath("argv-fixture.py")
> out = check_output([sys.executable, script, "foo", "bar"])
src/tests/test_sysargv.py:16:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/tests/_compat.py:71: in check_output
output = subprocess.check_output(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
popenargs = (['/users/isys/icronyn/pyenvs/tmp-2eb586eb98020886/bin/python', '/users/isys/icronyn/git/pythonnet/src/tests/fixtures/netstandard2.0/argv-fixture.py', 'foo', 'bar'],)
kwargs = {}, process = <subprocess.Popen object at 0x1c04a50>, output = ''
unused_err = None, retcode = 1
cmd = ['/users/isys/icronyn/pyenvs/tmp-2eb586eb98020886/bin/python', '/users/isys/icronyn/git/pythonnet/src/tests/fixtures/netstandard2.0/argv-fixture.py', 'foo', 'bar']
def check_output(*popenargs, **kwargs):
r"""Run command with arguments and return its output as a byte string.
If the exit code was non-zero it raises a CalledProcessError. The
CalledProcessError object will have the return code in the returncode
attribute and output in the output attribute.
The arguments are the same as for the Popen constructor. Example:
>>> check_output(["ls", "-l", "/dev/null"])
'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
The stdout argument is not allowed as it is used internally.
To capture standard error in the result, use stderr=STDOUT.
>>> check_output(["/bin/sh", "-c",
... "ls -l non_existent_file ; exit 0"],
... stderr=STDOUT)
'ls: non_existent_file: No such file or directory\n'
"""
if 'stdout' in kwargs:
raise ValueError('stdout argument not allowed, it will be overridden.')
process = Popen(stdout=PIPE, *popenargs, **kwargs)
output, unused_err = process.communicate()
retcode = process.poll()
if retcode:
cmd = kwargs.get("args")
if cmd is None:
cmd = popenargs[0]
> raise CalledProcessError(retcode, cmd, output=output)
E CalledProcessError: Command '['/users/isys/icronyn/pyenvs/tmp-2eb586eb98020886/bin/python', '/users/isys/icronyn/git/pythonnet/src/tests/fixtures/netstandard2.0/argv-fixture.py', 'foo', 'bar']' returned non-zero exit status 1
/usr/lib64/python2.7/subprocess.py:575: CalledProcessError
----------------------------- Captured stderr call -----------------------------
Traceback (most recent call last):
File "/users/isys/icronyn/git/pythonnet/src/tests/fixtures/netstandard2.0/argv-fixture.py", line 10, in <module>
import clr
ImportError: No module named clr |
@dmitriyse Below please find the tests that failed "normally" - some could be fixed by choosing classes that are part of .Net Standard 2.0 ...
|
The main problem here is the implicit assembly loading algorithm. It should be hard redesigned to allow to map class to an assembly under .Net Core 2.0. I did not try to figureout some solution. Maybe I will have some time to this at the Febrary. |
I already tried to link required nuget packages but this is not enough. |
To be honest, if I’m writing C# libs to be run in “full flavour” .Net 4, and in Core, I either need to stick to Standard 2.0 libraries, or I’m going to be using additional explicit references for Core. Maybe that’s the same for pythonnet? As far as the tests go, I was going to suggest changing them to use .Net Standard 2.0 types only - what do you think? |
Hi! I need to think about this solution. |
Please publish your changes in some temporary fork. |
.Net Core 2.1 preview should be released soon. So I prefere to wait it before resolve this issue, some differencies between Classic .Net Framework 4.x and .Net Core 2.0 will be resolved. |
Environment
Details
Describe what you were trying to get done.
pytest suite now works unly under Windows/Mono but not under .Net Core 2.0
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.
The text was updated successfully, but these errors were encountered: