Example #1
0
 def test_getlogin_bad(self):
     with mock.patch('os.getenv') as os_getenv:
         with mock.patch('os.getlogin') as os_getlogin:
             os_getenv.side_effect = [None, None, 'bar']
             os_getlogin.side_effect = OSError(
                 '[Errno 22] Invalid argument')
             self.assertEqual('bar', wrapper._getlogin())
             os_getlogin.assert_called_once_with()
             self.assertEqual(3, os_getenv.call_count)
Example #2
0
 def test_getlogin_bad(self):
     with mock.patch('os.getenv') as os_getenv:
         with mock.patch('os.getlogin') as os_getlogin:
             os_getenv.side_effect = [None, None, 'bar']
             os_getlogin.side_effect = OSError(
                 '[Errno 22] Invalid argument')
             self.assertEqual(wrapper._getlogin(), 'bar')
             os_getlogin.assert_called_once_with()
             self.assertEqual(os_getenv.call_count, 3)
Example #3
0
 def test_getlogin(self):
     with mock.patch('os.getlogin') as os_getlogin:
         os_getlogin.return_value = 'foo'
         self.assertEqual('foo', wrapper._getlogin())
Example #4
0
 def test_getlogin(self):
     with mock.patch('os.getlogin') as os_getlogin:
         os_getlogin.return_value = 'foo'
         self.assertEqual(wrapper._getlogin(), 'foo')