iki/monkeypatch

Python 3 compatible?

hoogervorst opened this issue · 5 comments

Getting an error while installing. Guess the code is not Python 3 compatible?

File "../T/pip-build-1rsdc20f/monkeypatch/setup.py", line 99
except ImportError, e:
^
SyntaxError: invalid syntax

No :) Not compatible. The same issue for me.

joaoe commented

This has been fixed long ago. Can be closed.

@joaoe This should not be closed without a fix released. According to the release notes, there was no release since 2011. "pip3 install monkeypatch" tries to install 0.1rc3. That's the most recent one, from 2011, but this was fixed in 2017. That fix hasn't found its way to the public yet.

I see this error today on the command line, using python 3.7.

@joaoe This should not be closed without a fix released. According to the release notes, there was no release since 2011. "pip3 install monkeypatch" tries to install 0.1rc3. That's the most recent one, from 2011, but this was fixed in 2017. That fix hasn't found its way to the public yet.

I see this error today on the command line, using python 3.7.

I totally quote. Trying to install it today as of May 2020 and pip3 cannot install it. The fix should be included in the release.

I overcame the problem by using monkeypatch differently. Monkeypatch is a module within a module: a module within pytest. I don't pip3 install it directly. I use it like so:

from _pytest.monkeypatch import MonkeyPatch

def _fake_subprocess_call(monkeypatch: MonkeyPatch):
     def _fake_subprocess_call( args, cwd ):
            do_whatever_other_thing(...)
     monkeypatch.setattr(function_i_made.subprocess, "run", _fake_subprocess_call)

I suggest removing it from pip3 entirely, if this is the way to do this in python3. And keep it there for python-2-based pip.