Fix mistakes in monkeypatch doc example
This commit is contained in:
parent
27577170e1
commit
f6c1e49287
|
@ -24,14 +24,14 @@ patch this function before calling into a function which uses it::
|
|||
|
||||
import os.path
|
||||
def getssh(): # pseudo application code
|
||||
return os.path.join(os.expanduser("~admin"), '.ssh')
|
||||
return os.path.join(os.path.expanduser("~admin"), '.ssh')
|
||||
|
||||
def test_mytest(monkeypatch):
|
||||
def mockreturn(path):
|
||||
return '/abc'
|
||||
monkeypatch.setattr(os.path, 'expanduser', mockreturn)
|
||||
x = getssh()
|
||||
assert x == '/abc'
|
||||
assert x == '/abc/.ssh'
|
||||
|
||||
After the test function finishes the ``os.path.expanduser`` modification
|
||||
will be undone.
|
||||
|
|
Loading…
Reference in New Issue