Skip to content

Instantly share code, notes, and snippets.

@previtus
Last active February 20, 2021 19:24
Show Gist options
  • Save previtus/fa4bada86ab654d84f2cb255725321aa to your computer and use it in GitHub Desktop.
Save previtus/fa4bada86ab654d84f2cb255725321aa to your computer and use it in GitHub Desktop.
Mock Settings
# v1
import mock
settings = mock.Mock()
settings.foo = 42
# v2
# works even when checking for non-existing entries...
from unittest.mock import Mock, MagicMock
args = MagicMock(name='method')
args.foo = 3
args.foo2 = 3
server = Server(args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment