/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Alexander Belchenko
  • Date: 2007-09-21 11:15:45 UTC
  • mto: This revision was merged to the branch mainline in revision 2884.
  • Revision ID: bialix@ukr.net-20070921111545-f2791vn4uk7chglw
test and fix for commit with bad non-ascii messages (non-ascii chars that cannot be decoded with current user encoding)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1148
1148
            'BZR_HOME': None, # Don't inherit BZR_HOME to all the tests.
1149
1149
            'HOME': os.getcwd(),
1150
1150
            'APPDATA': None,  # bzr now use Win32 API and don't rely on APPDATA
 
1151
            'BZR_EDITOR': None, # test_msgeditor manipulate with this variable
1151
1152
            'BZR_EMAIL': None,
1152
1153
            'BZREMAIL': None, # may still be present in the environment
1153
1154
            'EMAIL': None,
2671
2672
        else:
2672
2673
            return uni_val, str_val
2673
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