def test_close_fd_some_excepted(self): with mock.patch('os.sysconf') as mock_sysconf,\ mock.patch('os.close') as mock_close: mock_sysconf.return_value = 512 connection.close_fds(except_fds=[1, 2, 3]) self.assertEquals(mock_close.call_count, 509) with mock.patch('os.sysconf') as mock_sysconf,\ mock.patch('os.close') as mock_close: mock_sysconf.side_effect = ValueError() connection.close_fds(except_fds=[1, 2, 3]) self.assertEquals(mock_close.call_count, 1021)
def test_close_fd_some_excepted(self): with mock.patch('os.sysconf') as mock_sysconf,\ mock.patch('os.close') as mock_close: mock_sysconf.return_value = 512 connection.close_fds(except_fds=[1, 2, 3]) self.assertEquals(mock_close.call_count, 509) with mock.patch('os.sysconf') as mock_sysconf,\ mock.patch('os.close') as mock_close: mock_sysconf.side_effect = ValueError() connection.close_fds(except_fds=[1, 2, 3]) self.assertEquals(mock_close.call_count, 1021)
def test_close_fd_all_excepted(self): with mock.patch('os.sysconf') as mock_sysconf,\ mock.patch('os.close') as mock_close: mock_sysconf.return_value = 512 connection.close_fds(except_fds=range(512)) self.assertEquals(mock_close.call_count, 0) with mock.patch('os.sysconf') as mock_sysconf,\ mock.patch('os.close') as mock_close: mock_sysconf.side_effect = ValueError() connection.close_fds(except_fds=range(1024)) self.assertEquals(mock_close.call_count, 0)
def test_close_fd_all_excepted(self): with mock.patch('os.sysconf') as mock_sysconf,\ mock.patch('os.close') as mock_close: mock_sysconf.return_value = 512 connection.close_fds(except_fds=range(512)) self.assertEquals(mock_close.call_count, 0) with mock.patch('os.sysconf') as mock_sysconf,\ mock.patch('os.close') as mock_close: mock_sysconf.side_effect = ValueError() connection.close_fds(except_fds=range(1024)) self.assertEquals(mock_close.call_count, 0)