Пример #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(wrapper._getlogin(), "bar")
             os_getlogin.assert_called_once_with()
             self.assertEqual(os_getenv.call_count, 3)
Пример #2
0
 def test_getlogin(self):
     with mock.patch("os.getlogin") as os_getlogin:
         os_getlogin.return_value = "foo"
         self.assertEqual(wrapper._getlogin(), "foo")