Skip to content

Instantly share code, notes, and snippets.

@hiraq
Created August 26, 2016 16:12
Show Gist options
  • Save hiraq/d7f77d1ba9e218317ba9a7ecb2f12555 to your computer and use it in GitHub Desktop.
Save hiraq/d7f77d1ba9e218317ba9a7ecb2f12555 to your computer and use it in GitHub Desktop.
import unittest
import mock
from module.my_class_a import MyClassA
class TestMyClassA(unittest.TestCase):
def setUp(self):
self._fake_path = '/path/to/the/fake/yaml/file'
@mock.patch('module.my_class_a.yaml')
def test_to_test(self, mock_yaml):
mock_yaml.load = mock.MagicMock()
mock_yaml.load.return_value = dict(test='testing')
a = MyClassA()
output = a.to_test(self._fake_path)
self.assertEqual('testing', output['test'])
mock_yaml.load.assert_called_with()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment