Files
courses/py3interm/EXAMPLES/pytests/test_mock_pymock_barbecue.py
2025-05-20 11:57:43 -04:00

18 lines
397 B
Python

#!/usr/bin/env python
import pytest # <1>
import hamlib # <2>
class Barbecue(): # <3>
def doit(self): # <4>
return hamlib.ham(8)
def test_barbecue_doit_calls_ham(mocker): # <5>
mocker.patch('hamlib.ham') # <6>
b = Barbecue()
result = b.doit()
hamlib.ham.assert_called_once_with(8) # <9>
if __name__ == '__main__':
pytest.main([__file__, '-s']) # <10>