Switch off unittest verbosity
[zeroinstall/zeroinstall-mseaborn.git] / tests / testendtoend.py
bloba820c90bc306372990e0f40ff91b8fdacb59e799
1 #!/usr/bin/env python2.4
2 import os
3 import subprocess
4 import sys
5 import unittest
7 sys.path.insert(0, '..')
9 from basetest import BaseTest
10 from zeroinstall.injector import autopolicy
11 from zeroinstall.injector import run
12 from zeroinstall.injector.iface_cache import iface_cache
15 def write_file(filename, data):
16 fh = open(filename, "w")
17 try:
18 fh.write(data)
19 finally:
20 fh.close()
23 class TestEndToEnd(BaseTest):
24 def test(self):
25 tempdir = self.make_temp_dir()
26 feed_file = os.path.join(tempdir, "foo.xml")
27 write_file(feed_file, """
28 <interface xmlns="http://zero-install.sourceforge.net/2004/injector/interface">
29 <name>Test</name>
30 <summary>Placeholder</summary>
31 <group main="HelloWorld/main">
32 <implementation id="sha1=3ce644dc725f1d21cfcf02562c76f375944b266a"
33 version="1">
34 <archive href="%(dir)s/HelloWorld.tgz" size="176"/>
35 </implementation>
36 </group>
37 </interface>
38 """ % {"dir": os.path.abspath(os.path.dirname(__file__))})
39 policy = autopolicy.AutoPolicy(
40 feed_file, download_only=True, dry_run=False)
41 policy.download_and_execute([])
42 root_impl = policy.get_implementation(
43 iface_cache.get_interface(policy.root))
44 cmd_path = os.path.join(run._get_implementation_path(root_impl.id),
45 root_impl.main)
46 proc = subprocess.Popen([cmd_path], stdout=subprocess.PIPE)
47 stdout, stderr = proc.communicate()
48 self.assertEquals(proc.wait(), 0)
49 self.assertEquals(stdout, "Hello World\n")
52 suite = unittest.makeSuite(TestEndToEnd)
53 if __name__ == '__main__':
54 sys.argv.append('-v')
55 unittest.main()