~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-04 11:00:30 UTC
  • mto: This revision was merged to the branch mainline in revision 2800.
  • Revision ID: bialix@ukr.net-20070904110030-pma21wbsylstkdnv
support for non-ascii BZR_HOME in show_version()

Show diffs side-by-side

added added

removed removed

Lines of Context:
2641
2641
        new_id = "%s(%s)" % (new_test.id(), scenario[0])
2642
2642
        new_test.id = lambda: new_id
2643
2643
        return new_test
 
2644
 
 
2645
 
 
2646
def probe_unicode_in_user_encoding():
 
2647
    """Try to encode several unicode strings to use in unicode-aware tests.
 
2648
    Return first successfull match.
 
2649
 
 
2650
    :return:  (unicode value, encoded plain string value) or (None, None)
 
2651
    """
 
2652
    possible_vals = [u'm\xb5', u'\xe1', u'\u0410']
 
2653
    for uni_val in possible_vals:
 
2654
        try:
 
2655
            str_val = uni_val.encode(bzrlib.user_encoding)
 
2656
        except UnicodeEncodeError:
 
2657
            # Try a different character
 
2658
            pass
 
2659
        else:
 
2660
            return uni_val, str_val
 
2661
    return None, None