~james-w/udd/management-commands

« back to all changes in this revision

Viewing changes to udd/tests/__init__.py

  • Committer: James Westby
  • Date: 2011-12-13 21:09:23 UTC
  • mfrom: (557.1.1 drop_email_failures)
  • Revision ID: james.westby@canonical.com-20111213210923-tfrirlx3xbwmi70u
Merged drop_email_failures into management-commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
from bzrlib import tests
 
3
 
 
4
from udd import iconfig
 
5
 
 
6
class TestCaseWithConfig(tests.TestCaseWithTransport):
 
7
 
 
8
    def setUp(self):
 
9
        super(TestCaseWithConfig, self).setUp()
 
10
        # Since iconfig states that pkgimport.conf is part of the sources (or a
 
11
        # directory below), we can't directly use this file for testing.
 
12
        # Instead, we override _root_dir to be local to the test
 
13
        self.overrideAttr(iconfig, '_root_dir', self.test_dir)
 
14
        content = 'pi.base_dir=%s\n' % (self.test_dir,)
 
15
        self._set_store_content(iconfig.PkgimportStore(self.get_transport()),
 
16
                                content)
 
17
 
 
18
    def _set_store_content(self, store, content=None):
 
19
        # content may be unicode but the file content should be utf8
 
20
        content = content.encode('utf-8')
 
21
        store._load_from_string(content)
 
22
        store.save()
 
23
 
 
24
    def assertTestPathExists(self, relpath):
 
25
        self.assertPathExists(os.path.join(self.test_dir, relpath))
 
26