How do I import the pytest monkeypatch plugin?

Just to confirm Eric Fulmer's comment, if you do happen to want to use MonkeyPatch from within Python for whatever reason, it worked for me like this (based on The Compiler's answer)

from _pytest.monkeypatch import MonkeyPatch

def test_some_interaction(monkeypatch):
    monkeypatch.setattr("os.getcwd", lambda: "/")

test_some_interaction(MonkeyPatch())

It's not a plugin, it's a built-in pytest fixture.

In a nutshell, that means you simply write a test with a monkeypatch argument, and the test will get the monkeypatch object as that argument.

The page you linked has a simple example:

def test_some_interaction(monkeypatch):
    monkeypatch.setattr("os.getcwd", lambda: "/")