1944
1944
# GZ 2010-06-07: Note we can't actually grep for \u1234 as the pattern
1945
1945
# is mangled according to the user encoding.
1946
streams = self.run_bzr(["grep", "--files-with-matches",
1946
streams = self.run_bzr_raw(["grep", "--files-with-matches",
1947
1947
u"contents"], encoding="UTF-8")
1949
as_utf8 = as_utf8.encode("UTF-8")
1950
self.assertEqual(streams, (as_utf8 + "\n", ""))
1948
as_utf8 = as_utf8.encode("UTF-8")
1949
self.assertEqual(streams, (as_utf8 + b"\n", b""))
1952
streams = self.run_bzr(["grep", "-r", "1", "--files-with-matches",
1951
streams = self.run_bzr_raw(["grep", "-r", "1", "--files-with-matches",
1953
1952
u"contents"], encoding="UTF-8")
1954
self.assertEqual(streams, (as_utf8 + "~1\n", ""))
1953
self.assertEqual(streams, (as_utf8 + b"~1\n", b""))
1956
1955
fileencoding = osutils.get_user_encoding()
1957
1956
as_mangled = as_utf8.decode(fileencoding, "replace").encode("UTF-8")
1959
streams = self.run_bzr(["grep", "-n",
1958
streams = self.run_bzr_raw(["grep", "-n",
1960
1959
u"contents"], encoding="UTF-8")
1961
self.assertEqual(streams, ("%s:1:contents of %s\n" %
1962
(as_utf8, as_mangled), ""))
1960
self.assertEqual(streams, (b"%s:1:contents of %s\n" %
1961
(as_utf8, as_mangled), b""))
1964
streams = self.run_bzr(["grep", "-n", "-r", "1",
1963
streams = self.run_bzr_raw(["grep", "-n", "-r", "1",
1965
1964
u"contents"], encoding="UTF-8")
1966
self.assertEqual(streams, ("%s~1:1:contents of %s\n" %
1967
(as_utf8, as_mangled), ""))
1965
self.assertEqual(streams, (b"%s~1:1:contents of %s\n" %
1966
(as_utf8, as_mangled), b""))
1970
1969
class TestColorGrep(GrepTestBase):