Пример #1
0
 def test_PermissionError_with_user_specified_path(self):
     with patch('builtins.open', mock_open(read_data=_MOCK_CFG)) as m:
         m.side_effect = PermissionError
         with self.assertRaises(rcfile.RcFileError) as cm:
             rcfile.read('/path/to/nondefault/rc')
         self.assertIn('read', str(cm.exception).lower())
         self.assertIn('permission', str(cm.exception).lower())
Пример #2
0
 def test_PermissionError_with_default_path(self):
     with patch('builtins.open', mock_open(read_data=_MOCK_CFG)) as m:
         m.side_effect = PermissionError
         with self.assertRaises(rcfile.RcFileError) as cm:
             cmds = rcfile.read()
         self.assertIn('read', str(cm.exception).lower())
         self.assertIn('permission', str(cm.exception).lower())
Пример #3
0
 def test_FileNotFoundError_with_default_path(self):
     with patch('builtins.open', mock_open(read_data=_MOCK_CFG)) as m:
         m.side_effect = FileNotFoundError
         cmds = rcfile.read()
     self.assertEqual(cmds, ())
Пример #4
0
 def test_ignoring_comments_and_empty_lines(self):
     with patch('builtins.open', mock_open(read_data=_MOCK_CFG)):
         cmds = rcfile.read()
     self.assertEqual(tuple(cmds), ('foo bar baz', 'foo', 'faboobarbaz'))