Skip to content

Instantly share code, notes, and snippets.

@rishabh-ink
Last active March 23, 2019 23:27
Show Gist options
  • Save rishabh-ink/d757a732d674945b361244f12e55a720 to your computer and use it in GitHub Desktop.
Save rishabh-ink/d757a732d674945b361244f12e55a720 to your computer and use it in GitHub Desktop.
Of pytest and lru_cache in Python
from unittest import mock
import pytest
@pytest.mark.parametrize(
'ordinary_object',
[
'quill',
'cushion',
'cauldron',
],
)
def test_levitate_casts_a_spell(ordinary_object):
with mock.patch(
'levitation.cast_spell',
autospec=True,
) as patched_cast_spell:
levitate.cache_clear()
levitate(ordinary_object)
patched_cast_spell.assert_called_once_with(target=ordinary_object)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment