/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 breezy/tests/blackbox/test_command_encoding.py

  • Committer: Jelmer Vernooij
  • Date: 2018-08-13 01:38:21 UTC
  • mto: This revision was merged to the branch mainline in revision 7078.
  • Revision ID: jelmer@jelmer.uk-20180813013821-ftxhownoxs1l55qs
Fix some more tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
    def test_exact(self):
52
52
        def bzr(*args, **kwargs):
53
53
            kwargs['encoding'] = 'ascii'
54
 
            return self.run_bzr(*args, **kwargs)[0]
 
54
            return self.run_bzr_raw(*args, **kwargs)[0]
55
55
 
56
56
        register_command(cmd_echo_exact)
57
57
        try:
58
 
            self.assertEqual('foo', bzr('echo-exact foo'))
 
58
            self.assertEqual(b'foo', bzr('echo-exact foo'))
59
59
            # Exact should fail to decode the string
60
60
            self.assertRaises(UnicodeEncodeError,
61
61
                bzr,
68
68
    def test_strict_utf8(self):
69
69
        def bzr(*args, **kwargs):
70
70
            kwargs['encoding'] = 'utf-8'
71
 
            return self.run_bzr(*args, **kwargs)[0]
 
71
            return self.run_bzr_raw(*args, **kwargs)[0]
72
72
 
73
73
        register_command(cmd_echo_strict)
74
74
        try:
75
 
            self.assertEqual('foo', bzr('echo-strict foo'))
 
75
            self.assertEqual(b'foo', bzr('echo-strict foo'))
76
76
            expected = u'foo\xb5'
77
 
            if not PY3:
78
 
                expected = expected.encode('utf-8')
 
77
            expected = expected.encode('utf-8')
79
78
            self.assertEqual(expected,
80
79
                             bzr(['echo-strict', u'foo\xb5']))
81
80
        finally:
84
83
    def test_strict_ascii(self):
85
84
        def bzr(*args, **kwargs):
86
85
            kwargs['encoding'] = 'ascii'
87
 
            return self.run_bzr(*args, **kwargs)[0]
 
86
            return self.run_bzr_raw(*args, **kwargs)[0]
88
87
 
89
88
        register_command(cmd_echo_strict)
90
89
        try:
91
 
            self.assertEqual('foo', bzr('echo-strict foo'))
 
90
            self.assertEqual(b'foo', bzr('echo-strict foo'))
92
91
            # ascii can't encode \xb5
93
92
            self.assertRaises(UnicodeEncodeError,
94
93
                bzr,
99
98
    def test_replace_utf8(self):
100
99
        def bzr(*args, **kwargs):
101
100
            kwargs['encoding'] = 'utf-8'
102
 
            return self.run_bzr(*args, **kwargs)[0]
 
101
            return self.run_bzr_raw(*args, **kwargs)[0]
103
102
 
104
103
        register_command(cmd_echo_replace)
105
104
        try:
106
 
            self.assertEqual('foo', bzr('echo-replace foo'))
 
105
            self.assertEqual(b'foo', bzr('echo-replace foo'))
107
106
            self.assertEqual(u'foo\xb5'.encode('utf-8'),
108
107
                             bzr(['echo-replace', u'foo\xb5']))
109
108
        finally:
112
111
    def test_replace_ascii(self):
113
112
        def bzr(*args, **kwargs):
114
113
            kwargs['encoding'] = 'ascii'
115
 
            return self.run_bzr(*args, **kwargs)[0]
 
114
            return self.run_bzr_raw(*args, **kwargs)[0]
116
115
 
117
116
        register_command(cmd_echo_replace)
118
117
        try:
119
 
            self.assertEqual('foo', bzr('echo-replace foo'))
 
118
            self.assertEqual(b'foo', bzr('echo-replace foo'))
120
119
            # ascii can't encode \xb5
121
 
            self.assertEqual('foo?', bzr(['echo-replace', u'foo\xb5']))
 
120
            self.assertEqual(b'foo?', bzr(['echo-replace', u'foo\xb5']))
122
121
        finally:
123
122
            plugin_cmds.remove('echo-replace')
124
123