Created
February 24, 2016 17:37
-
-
Save blackjack/413061143f1974284d3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mock.patch('__builtin__.open', create=True) | |
def test_cmd_config_basic_items(self, mock_open): | |
test = """ | |
# comment | |
stringkey1 = stringvalue1 | |
stringkey2 = "stringvalue2" | |
intkey = 1234 | |
floatkey = 56.78 | |
bool1 = yes | |
bool2 = No | |
bool3 = y | |
""" | |
mock_content = mock.MagicMock() | |
mock_content.__iter__.return_value = test.split('\n') | |
mock_open.return_value = mock_content | |
cfg = config.parse('cmd.conf') | |
mock_open.assert_called_once_with('cmd.conf') | |
self.assertFalse('comment' in cfg) | |
self.assertEqual(cfg['stringkey1'], 'stringvalue1') | |
self.assertEqual(cfg['stringkey2'], 'stringvalue2') | |
self.assertEqual(cfg['intkey'], 1234) | |
self.assertEqual(cfg['floatkey'], 56.78) | |
self.assertEqual(cfg['bool1'], True) | |
self.assertEqual(cfg['bool2'], False) | |
self.assertEqual(cfg['bool3'], True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment