1
# Copyright (C) 2007, 2008 Canonical Ltd
1
# Copyright (C) 2007-2012, 2016 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
39
39
output = self.run_bzr('version')[0]
40
40
self.log('bzr version output:')
42
self.assert_(output.startswith('Bazaar (bzr) '))
42
self.assertTrue(output.startswith('Bazaar (bzr) '))
43
43
self.assertNotEqual(output.index('Canonical'), -1)
44
44
# make sure --version is consistent
45
45
tmp_output = self.run_bzr('--version')[0]
46
self.assertEquals(output, tmp_output)
46
self.assertEqual(output, tmp_output)
48
48
def test_version(self):
49
49
self.permit_source_tree_branch_repo()
95
95
raise TestSkipped('Cannot find a unicode character that works in'
96
96
' encoding %s' % (osutils.get_user_encoding(),))
98
osutils.set_or_unset_env('BZR_HOME', str_val)
98
self.overrideEnv('BZR_HOME', str_val)
99
99
self.permit_source_tree_branch_repo()
100
100
out = self.run_bzr("version")[0]
101
101
self.assertTrue(len(out) > 0)
107
107
def test_simple(self):
108
108
bzr_log = 'my.bzr.log'
109
osutils.set_or_unset_env('BZR_LOG', bzr_log)
109
self.overrideEnv('BZR_LOG', bzr_log)
110
110
default_log = os.path.join(os.environ['BZR_HOME'], '.bzr.log')
111
self.failIfExists([default_log, bzr_log])
111
self.assertPathDoesNotExist([default_log, bzr_log])
112
112
out = self.run_bzr_subprocess('version')[0]
113
113
self.assertTrue(len(out) > 0)
114
114
self.assertContainsRe(out, r"(?m)^ Bazaar log file: " + bzr_log)
115
self.failIfExists(default_log)
116
self.failUnlessExists(bzr_log)
115
self.assertPathDoesNotExist(default_log)
116
self.assertPathExists(bzr_log)
118
118
def test_dev_null(self):
119
119
# This test uses a subprocess to cause the log opening logic to
124
124
bzr_log = '/dev/null'
125
osutils.set_or_unset_env('BZR_LOG', bzr_log)
125
self.overrideEnv('BZR_LOG', bzr_log)
126
126
default_log = os.path.join(os.environ['BZR_HOME'], '.bzr.log')
127
self.failIfExists(default_log)
127
self.assertPathDoesNotExist(default_log)
128
128
out = self.run_bzr_subprocess('version')[0]
129
129
self.assertTrue(len(out) > 0)
130
130
self.assertContainsRe(out, r"(?m)^ Bazaar log file: " + bzr_log)
131
self.failIfExists(default_log)
131
self.assertPathDoesNotExist(default_log)
133
def test_unicode_bzr_log(self):
135
enc = osutils.get_user_encoding()
137
str_val = uni_val.encode(enc)
138
except UnicodeEncodeError:
139
self.skip("Test string %r unrepresentable in user encoding %s" % (
141
self.overrideEnv('BZR_HOME', self.test_base_dir)
142
self.overrideEnv("BZR_LOG",
143
os.path.join(self.test_base_dir, uni_val).encode(enc))
144
out, err = self.run_bzr_subprocess("version")
145
uni_out = out.decode(enc)
146
self.assertContainsRe(uni_out, u"(?m)^ Bazaar log file: .*/\xa7$")