def test_fd_by_path(): test_file = tempfile.NamedTemporaryFile() try: keep = fd_by_path([test_file.name]) assert keep == [test_file.file.fileno()] with patch('os.open') as _open: _open.side_effect = OSError() assert not fd_by_path([test_file.name]) finally: test_file.close()
def test_finds(self): test_file = tempfile.NamedTemporaryFile() try: keep = fd_by_path([test_file.name]) self.assertEqual(keep, [test_file.file.fileno()]) with patch('os.open') as _open: _open.side_effect = OSError() self.assertFalse(fd_by_path([test_file.name])) finally: test_file.close()
def test_finds(self): test_file = tempfile.NamedTemporaryFile() keep = fd_by_path([test_file.name]) self.assertEqual(keep, [test_file.file.fileno()]) test_file.close()