You can overwrite pretty much anything in Python at runtime, and the mock tooling in the standard library can help you with that, if you can't straight up just override a method or object.

Global vars?

So with a Singleton what you can do at least in Java land is have your service invoke the method to get the Singleton semi-global object.

So you can mock that method invocation to return a different object. So you basically have the local object to play with in your test and won't be affecting any actual real global state

But basically the article was just saying just use global variables. Does python have a means for then intercepting the value request and data assignments for that global variable for the local scope of the testing code? Or is it hardwired like a global variable, presumably is?

I'm tired and I'm not sure I understood your question correctly, sorry if it doesn't address your point:

In python test library, you have something called 'monkeypatch' that allows you to intercept calls to specific functions or classes and set the response yourself (I mostly use it to mock API responses tbh but it can do a lot more, an really complex operations). Monkeypatch only operate in the scope of the function or file it's written in (I think. I only remember using it in unit test functions).

The answer if I understand correctly is if you want to use testing frameworks in Python, you should probably not be using global variables and you should probably actually be using the Singleton pattern.

Python test frameworks generally do mocking by monkey-patching, and they take care of it for you. This does not generally require global state, either in the form of module-level variables or singletons. It works by doing things like replacing the attributes of an existing class or module object. (Python takes "everything is an object" seriously, so a module is an object whose attributes are the functions, classes and other global variables of the corresponding file's code, roughly speaking. It is not simply reflected as such through a reflection API, like in Java; it is directly represented with an object. This is the sort of benefit dynamic typing gets you, along with the object-qua-dictionary-of-attributes model.)