~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_command_encoding.py

  • Committer: Patch Queue Manager
  • Date: 2016-04-21 04:10:52 UTC
  • mfrom: (6616.1.1 fix-en-user-guide)
  • Revision ID: pqm@pqm.ubuntu.com-20160421041052-clcye7ns1qcl2n7w
(richard-wilbur) Ensure build of English use guide always uses English text
 even when user's locale specifies a different language. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Tests for the Command.encoding_type interface."""
18
18
 
46
46
 
47
47
 
48
48
class TestCommandEncoding(TestCase):
49
 
    
 
49
 
50
50
    def test_exact(self):
51
51
        def bzr(*args, **kwargs):
52
52
            return self.run_bzr(*args, **kwargs)[0]
54
54
        register_command(cmd_echo_exact)
55
55
        try:
56
56
            self.assertEqual('foo', bzr('echo-exact foo'))
57
 
            # This is cheating a little bit, because 'foo\xb5' shouldn't
58
 
            # get past main()
59
 
            self.assertEqual('foo\xb5', bzr('echo-exact foo\xb5'))
60
57
            # Exact should fail to decode the string
61
58
            self.assertRaises(UnicodeEncodeError,
62
59
                bzr,
63
60
                ['echo-exact', u'foo\xb5'])
 
61
            # Previously a non-ascii bytestring was also tested, as 'exact'
 
62
            # outputs bytes untouched, but needed buggy argv parsing to work
64
63
        finally:
65
 
            plugin_cmds.pop('echo-exact')
 
64
            plugin_cmds.remove('echo-exact')
66
65
 
67
66
    def test_strict_utf8(self):
68
67
        def bzr(*args, **kwargs):
75
74
            self.assertEqual(u'foo\xb5'.encode('utf-8'),
76
75
                             bzr(['echo-strict', u'foo\xb5']))
77
76
        finally:
78
 
            plugin_cmds.pop('echo-strict')
 
77
            plugin_cmds.remove('echo-strict')
79
78
 
80
79
    def test_strict_ascii(self):
81
80
        def bzr(*args, **kwargs):
90
89
                bzr,
91
90
                ['echo-strict', u'foo\xb5'])
92
91
        finally:
93
 
            plugin_cmds.pop('echo-strict')
 
92
            plugin_cmds.remove('echo-strict')
94
93
 
95
94
    def test_replace_utf8(self):
96
95
        def bzr(*args, **kwargs):
103
102
            self.assertEqual(u'foo\xb5'.encode('utf-8'),
104
103
                             bzr(['echo-replace', u'foo\xb5']))
105
104
        finally:
106
 
            plugin_cmds.pop('echo-replace')
 
105
            plugin_cmds.remove('echo-replace')
107
106
 
108
107
    def test_replace_ascii(self):
109
108
        def bzr(*args, **kwargs):
116
115
            # ascii can't encode \xb5
117
116
            self.assertEqual('foo?', bzr(['echo-replace', u'foo\xb5']))
118
117
        finally:
119
 
            plugin_cmds.pop('echo-replace')
 
118
            plugin_cmds.remove('echo-replace')
120
119
 
121
120