2 from basetest
import BaseTest
3 import os
, sys
, subprocess
5 from StringIO
import StringIO
7 sys
.path
.insert(0, '..')
9 from zeroinstall
.injector
import policy
, run
, handler
, model
11 mydir
= os
.path
.abspath(os
.path
.dirname(__file__
))
12 local_0launch
= os
.path
.join(os
.path
.dirname(mydir
), '0launch')
13 runnable
= os
.path
.join(mydir
, 'runnable', 'Runnable.xml')
15 class TestRun(BaseTest
):
16 def testRunnable(self
):
17 child
= subprocess
.Popen([local_0launch
, '--', runnable
, 'user-arg'], stdout
= subprocess
.PIPE
)
18 stdout
, _
= child
.communicate()
19 assert 'Args: command-arg -- user-arg' in stdout
, stdout
21 def testCommandBindings(self
):
22 command_feed
= os
.path
.join(mydir
, 'Command.xml')
24 p
= policy
.Policy(command_feed
, handler
= h
)
25 h
.wait_for_blocker(p
.solve_with_downloads())
26 old_stdout
= sys
.stdout
28 sys
.stdout
= StringIO()
29 run
.execute_selections(p
.solver
.selections
, [], main
= '.', dry_run
= True)
31 sys
.stdout
= old_stdout
32 assert 'local' in os
.environ
['LOCAL'], os
.environ
['LOCAL']
34 if __name__
== '__main__':