1 #!/usr/bin/env python2.4
2 import sys
, tempfile
, os
, shutil
, StringIO
6 # Catch silly mistakes...
7 os
.environ
['HOME'] = '/home/idontexist'
9 sys
.path
.insert(0, '..')
10 from zeroinstall
.injector
import trust
, basedir
, autopolicy
, namespaces
, qdom
11 from zeroinstall
.injector
import model
, iface_cache
, cli
, download
, writer
, distro
12 from zeroinstall
.zerostore
import Store
; Store
._add
_with
_helper
= lambda *unused
: False
13 from zeroinstall
import support
15 dpkgdir
= os
.path
.join(os
.path
.dirname(__file__
), 'dpkg')
17 empty_feed
= qdom
.parse(StringIO
.StringIO("""<interface xmlns='http://zero-install.sourceforge.net/2004/injector/interface'>
19 <summary>just for testing</summary>
22 class BaseTest(unittest
.TestCase
):
24 self
.config_home
= tempfile
.mktemp()
25 self
.cache_home
= tempfile
.mktemp()
26 self
.cache_system
= tempfile
.mktemp()
27 self
.gnupg_home
= tempfile
.mktemp()
28 os
.environ
['GNUPGHOME'] = self
.gnupg_home
29 os
.environ
['XDG_CONFIG_HOME'] = self
.config_home
30 os
.environ
['XDG_CACHE_HOME'] = self
.cache_home
31 os
.environ
['XDG_CACHE_DIRS'] = self
.cache_system
33 assert basedir
.xdg_config_home
== self
.config_home
34 iface_cache
.iface_cache
.__init
__()
36 os
.mkdir(self
.config_home
, 0700)
37 os
.mkdir(self
.cache_home
, 0700)
38 os
.mkdir(self
.cache_system
, 0500)
39 os
.mkdir(self
.gnupg_home
, 0700)
41 if os
.environ
.has_key('DISPLAY'):
42 del os
.environ
['DISPLAY']
43 namespaces
.injector_gui_uri
= os
.path
.join(os
.path
.dirname(__file__
), 'test-gui.xml')
45 logging
.getLogger().setLevel(logging
.WARN
)
47 download
._downloads
= {}
49 self
.old_path
= os
.environ
['PATH']
50 os
.environ
['PATH'] = dpkgdir
+ ':' + self
.old_path
52 distro
._host
_distribution
= distro
.DebianDistribution(dpkgdir
)
55 shutil
.rmtree(self
.config_home
)
56 support
.ro_rmtree(self
.cache_home
)
57 shutil
.rmtree(self
.cache_system
)
58 shutil
.rmtree(self
.gnupg_home
)
60 os
.environ
['PATH'] = self
.old_path