def test_temporary_files_failed_cleanup(caplog, qtbot, py_proc, runner):
 (cmd, args) = py_proc("\n        import os\n        os.remove(os.environ['QUTE_HTML'])\n    ")
 with caplog.at_level(logging.ERROR):
  with qtbot.waitSignal(runner.finished, timeout=10000):
   runner.prepare_run(cmd, *args)
   runner.store_text('')
   runner.store_html('')
 assert (len(caplog.records) == 1)
 expected = 'Failed to delete tempfile'
 assert caplog.records[0].message.startswith(expected)

def test_temporary_files_failed_cleanup ( caplog , qtbot , py_proc , runner ) : ( cmd , args ) = py_proc ( "\n        import os\n        os.remove(os.environ['QUTE_HTML'])\n    " ) with caplog . at_level ( logging . ERROR ) : with qtbot . waitSignal ( runner . finished , timeout = 10000 ) : runner . prepare_run ( cmd , * args ) runner . store_text ( '' ) runner . store_html ( '' ) assert ( len ( caplog . records ) == 1 ) expected = 'Failed to delete tempfile' assert caplog . records [ 0 ] . message . startswith ( expected )
delete a temporary file from the script so cleanup fails .