case.pytest
¶
-
class
case.pytest.
fixture_with_options
(marker_name=None)[source]¶ Pytest fixture with options specified in separate decrorator.
The decorated fixture MUST take the request fixture as first argument, but is free to use other fixtures.
- Example:
@fixture_with_options() def sftp(request,
username=’test_username’, password=’test_password’):return {‘username’: username, ‘password’: password}
@sftp.options(username=’foo’, password=’bar’) def test_foo(sftp):
assert sftp[‘username’] == ‘foo’ assert sftp[‘password’] == ‘bar’
-
case.pytest.
patching
(monkeypatch, request)[source]¶ Monkeypath.setattr shortcut.
- Example:
- def test_foo(patching):
# execv value here will be mock.MagicMock by default. execv = patching(‘os.execv’)
patching(‘sys.platform’, ‘darwin’) # set concrete value patching.setenv(‘DJANGO_SETTINGS_MODULE’, ‘x.settings’)
# val will be of type mock.MagicMock by default val = patching.setitem(‘path.to.dict’, ‘KEY’)