Esempio n. 1
0
 def test_other_oserror(self, c):
     with self.assertRaises(OSError):
         c.side_effect = OSError(3, os.strerror(3))
         scaffold.call_if_exists(
             ('hello', 'world'),
             'No such process would be a weird error to get here'
         )
Esempio n. 2
0
 def test_oserror(self, c):
     c.side_effect = OSError(2, os.strerror(2))
     with patch.object(scaffold, 'write'):
         return_value = scaffold.call_if_exists(('hello', 'world'),
                                                'Sorry no greetings')
         self.assertEqual(False, return_value)
         scaffold.write.assert_any_call('Sorry no greetings')
Esempio n. 3
0
 def test_file_not_found_err(self, c):
     if getattr(__builtins__, 'FileNotFoundError', None):
         c.side_effect = FileNotFoundError(2, os.strerror(2))
         with patch.object(scaffold, 'write'):
             return_value = scaffold.call_if_exists(('hello', 'world'),
                                                    'Sorry no greetings')
             self.assertEqual(False, return_value)
             scaffold.write.assert_any_call('Sorry no greetings')
Esempio n. 4
0
 def test_oserror(self, c):
     c.side_effect = OSError(2, os.strerror(2))
     with patch.object(scaffold, 'write'):
         return_value = scaffold.call_if_exists(
             ('hello', 'world'),
             'Sorry no greetings'
         )
         self.assertEqual(False, return_value)
         scaffold.write.assert_any_call('Sorry no greetings')
Esempio n. 5
0
 def test_file_not_found_err(self, c):
     if getattr(__builtins__, 'FileNotFoundError', None):
         c.side_effect = FileNotFoundError(2, os.strerror(2))
         with patch.object(scaffold, 'write'):
             return_value = scaffold.call_if_exists(
                 ('hello', 'world'),
                 'Sorry no greetings'
             )
             self.assertEqual(False, return_value)
             scaffold.write.assert_any_call('Sorry no greetings')
Esempio n. 6
0
 def test_other_oserror(self, c):
     with self.assertRaises(OSError):
         c.side_effect = OSError(3, os.strerror(3))
         scaffold.call_if_exists(
             ('hello', 'world'),
             'No such process would be a weird error to get here')
Esempio n. 7
0
 def test_success(self, c):
     self.assertEqual(
         True,
         scaffold.call_if_exists(('hello', 'world'), 'Sorry, no greetings'))
Esempio n. 8
0
 def test_success(self, c):
     self.assertEqual(
         True,
         scaffold.call_if_exists(('hello', 'world'), 'Sorry, no greetings')
     )