~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Alexander Belchenko
  • Date: 2007-09-06 11:59:59 UTC
  • mto: (2839.6.2 3)
  • mto: This revision was merged to the branch mainline in revision 2884.
  • Revision ID: bialix@ukr.net-20070906115959-512lrh7jb9rll98d
some win32-specific fixes for selftest

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
    pass
73
73
from bzrlib.merge import merge_inner
74
74
import bzrlib.merge3
75
 
import bzrlib.osutils
76
75
import bzrlib.plugin
77
76
from bzrlib.revision import common_ancestor
78
77
import bzrlib.store
1148
1147
            'BZR_HOME': None, # Don't inherit BZR_HOME to all the tests.
1149
1148
            'HOME': os.getcwd(),
1150
1149
            'APPDATA': None,  # bzr now use Win32 API and don't rely on APPDATA
 
1150
            'BZR_EDITOR': None, # test_msgeditor manipulate with this variable
1151
1151
            'BZR_EMAIL': None,
1152
1152
            'BZREMAIL': None, # may still be present in the environment
1153
1153
            'EMAIL': None,
1320
1320
            working_dir):
1321
1321
        """Run bazaar command line, splitting up a string command line."""
1322
1322
        if isinstance(args, basestring):
1323
 
            args = list(shlex.split(args))
 
1323
            # shlex don't understand unicode strings,
 
1324
            # so args should be plain string (bialix 20070906)
 
1325
            args = list(shlex.split(str(args)))
1324
1326
        return self._run_bzr_core(args, retcode=retcode,
1325
1327
                encoding=encoding, stdin=stdin, working_dir=working_dir,
1326
1328
                )
1878
1880
    def _make_test_root(self):
1879
1881
        if TestCaseWithMemoryTransport.TEST_ROOT is not None:
1880
1882
            return
1881
 
        root = tempfile.mkdtemp(prefix='testbzr-', suffix='.tmp')
 
1883
        root = osutils.mkdtemp(prefix='testbzr-', suffix='.tmp')
1882
1884
        TestCaseWithMemoryTransport.TEST_ROOT = root
1883
1885
        
1884
1886
        # make a fake bzr directory there to prevent any tests propagating
1994
1996
        name and then create two subdirs - test and home under it.
1995
1997
        """
1996
1998
        # create a directory within the top level test directory
1997
 
        candidate_dir = tempfile.mkdtemp(dir=self.TEST_ROOT)
 
1999
        candidate_dir = osutils.mkdtemp(dir=self.TEST_ROOT)
1998
2000
        # now create test and home directories within this dir
1999
2001
        self.test_base_dir = candidate_dir
2000
2002
        self.test_home_dir = self.test_base_dir + '/home'
2670
2672
        else:
2671
2673
            return uni_val, str_val
2672
2674
    return None, None
 
2675
 
 
2676
 
 
2677
def probe_bad_non_ascii_in_user_encoding():
 
2678
    """Try to find [bad] character with code [128..255]
 
2679
    that cannot be decoded to unicode in user_encoding.
 
2680
    Return None if all non-ascii characters is valid
 
2681
    for current user_encoding.
 
2682
    """
 
2683
    for i in xrange(128, 256):
 
2684
        char = chr(i)
 
2685
        try:
 
2686
            char.decode(bzrlib.user_encoding)
 
2687
        except UnicodeDecodeError:
 
2688
            return char
 
2689
    return None