def test_source(qtbot, py_proc, runner):
 (cmd, args) = py_proc("\n        import os\n        import json\n\n        data = {\n            'html_file': os.environ['QUTE_HTML'],\n            'text_file': os.environ['QUTE_TEXT'],\n        }\n\n        with open(os.environ['QUTE_HTML'], 'r') as f:\n            data['html'] = f.read()\n\n        with open(os.environ['QUTE_TEXT'], 'r') as f:\n            data['text'] = f.read()\n\n        with open(os.environ['QUTE_FIFO'], 'w') as f:\n            json.dump(data, f)\n            f.write('\\n')\n    ")
 with qtbot.waitSignal(runner.finished, timeout=10000):
  with qtbot.waitSignal(runner.got_cmd, timeout=10000) as blocker:
   runner.prepare_run(cmd, *args)
   runner.store_html('This is HTML')
   runner.store_text('This is text')
 data = blocker.args[0]
 parsed = json.loads(data)
 assert (parsed['text'] == 'This is text')
 assert (parsed['html'] == 'This is HTML')
 assert (not os.path.exists(parsed['text_file']))
 assert (not os.path.exists(parsed['html_file']))

def test_source ( qtbot , py_proc , runner ) : ( cmd , args ) = py_proc ( "\n        import os\n        import json\n\n        data = {\n            'html_file': os.environ['QUTE_HTML'],\n            'text_file': os.environ['QUTE_TEXT'],\n        }\n\n        with open(os.environ['QUTE_HTML'], 'r') as f:\n            data['html'] = f.read()\n\n        with open(os.environ['QUTE_TEXT'], 'r') as f:\n            data['text'] = f.read()\n\n        with open(os.environ['QUTE_FIFO'], 'w') as f:\n            json.dump(data, f)\n            f.write('\\n')\n    " ) with qtbot . waitSignal ( runner . finished , timeout = 10000 ) : with qtbot . waitSignal ( runner . got_cmd , timeout = 10000 ) as blocker : runner . prepare_run ( cmd , * args ) runner . store_html ( 'This is HTML' ) runner . store_text ( 'This is text' ) data = blocker . args [ 0 ] parsed = json . loads ( data ) assert ( parsed [ 'text' ] == 'This is text' ) assert ( parsed [ 'html' ] == 'This is HTML' ) assert ( not os . path . exists ( parsed [ 'text_file' ] ) ) assert ( not os . path . exists ( parsed [ 'html_file' ] ) )
make sure the page source is read and cleaned up correctly .