a ze@shdZddlZddlmZddlZddlZejZdevrBdedZGdddejZ e dkrde dS) zQBasic tests for os.popen() Particularly useful for platforms that fake popen. N)support "c@s<eZdZddZddZddZddZd d Zd d Zd S) PopenTestcCsbd}|t|f}t|}|}Wdn1s80Yt|dd}|||dS)Nz&%s -c "import sys; print(sys.argv)" %s)pythonospopenreadeval assertEqual)selfZcmdlineZexpectedcmdpdataZgotrC/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_popen.py_do_test_commandlines   &zPopenTest._do_test_commandlinecCsJ|ttj|dddg|dgd|dgdtdS)Nzfoo barfoobarz foo "spam and eggs" "silly walk")rz spam and eggsz silly walkzfoo "a \"quoted\" arg" bar)rza "quoted" argr)Z assertRaises TypeErrorrr rr reap_childrenr rrr test_popenszPopenTest.test_popencCsR|tddtd}tjdkr<||dn|t|ddS)Nexit 0zexit 42nt*)r rr closenamewaitstatus_to_exitcode)r statusrrrtest_return_code-s  zPopenTest.test_return_codecCs>td }||dWdn1s00YdSNz echo hellozhello )rr r r r frrrtest_contextmanager5s zPopenTest.test_contextmanagercCs@td"}|t|dgWdn1s20YdSr")rr r listr#rrrtest_iterating9s zPopenTest.test_iteratingcCs4tjddddWdn1s&0YdS)Nrw)rmode buffering)rr rrrr test_keywords=szPopenTest.test_keywordsN) __name__ __module__ __qualname__rrr!r%r'r,rrrrrs r__main__) __doc__Zunittesttestrrsys executablerZTestCaserr-mainrrrrs  .