2 import sys
, tempfile
, os
, subprocess
5 zeroinstall_dir
= os
.environ
.get('0EXPORT_ZEROINSTALL', None)
7 sys
.path
.insert(1, zeroinstall_dir
)
9 from zeroinstall
.support
import ro_rmtree
11 my_dir
= os
.path
.dirname(os
.path
.abspath(__file__
))
13 export_bin
= os
.path
.join(my_dir
, '0export')
15 PUBLISH_URI
= 'http://0install.net/2006/interfaces/0publish'
17 class TestExport(unittest
.TestCase
):
20 self
.tmpdir
= tempfile
.mkdtemp(prefix
= '0export-test-')
22 # tmpdir is used as $HOME when running the bundle...
23 config_dir
= os
.path
.join(self
.tmpdir
, '.config', '0install.net', 'injector')
24 os
.makedirs(config_dir
)
25 stream
= open(os
.path
.join(config_dir
, 'global'), 'w')
26 stream
.write('[global]\n'
28 'help_with_testing = False\n'
29 'network_use = off-line\n')
33 ro_rmtree(self
.tmpdir
)
36 setup_sh
= os
.path
.join(self
.tmpdir
, 'setup.sh')
37 subprocess
.check_call([sys
.executable
, export_bin
, setup_sh
, PUBLISH_URI
])
41 'http_proxy' : 'localhost:1111', # Detect accidental network access
42 'PATH': '/bin:/usr/bin:' + os
.path
.dirname(sys
.executable
),
43 #'LANG': 'en_GB.utf-8', # Hack for 0install < 2.2 on ArchLinux
46 child
= subprocess
.Popen([setup_sh
, '--help'], env
= env
, stdout
= subprocess
.PIPE
)
47 cout
, unused
= child
.communicate()
48 assert child
.wait() == 0
49 assert 'Run self-extracting installer' in cout
51 child
= subprocess
.Popen([setup_sh
, '--', '--help'], env
= env
, stdout
= subprocess
.PIPE
)
52 cout
, unused
= child
.communicate()
53 assert child
.wait() == 0, cout
54 assert '--xmlsign' in cout
, cout
56 suite
= unittest
.makeSuite(TestExport
)
57 if __name__
== '__main__':