/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/plugins/git/tests/test_blackbox.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-13 22:54:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6968.
  • Revision ID: jelmer@jelmer.uk-20180513225428-5ysu0bs9rtk7045h
Initial work to support brz-git on python3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
        dir = ControlDir.open(self.test_dir)
55
55
        dir.create_branch()
56
56
        output, error = self.run_bzr(['nick'])
57
 
        self.assertEquals("master\n", output)
 
57
        self.assertEquals(b"master\n", output)
58
58
 
59
59
    def test_branches(self):
60
60
        self.simple_commit()
61
61
        output, error = self.run_bzr(['branches'])
62
 
        self.assertEquals("* master\n", output)
 
62
        self.assertEquals(b"* master\n", output)
63
63
 
64
64
    def test_info(self):
65
65
        self.simple_commit()
66
66
        output, error = self.run_bzr(['info'])
67
67
        self.assertEqual(error, '')
68
 
        self.assertTrue("Standalone tree (format: git)" in output)
 
68
        self.assertTrue(b"Standalone tree (format: git)" in output)
69
69
 
70
70
    def test_branch(self):
71
71
        os.mkdir("gitbranch")
72
72
        GitRepo.init(os.path.join(self.test_dir, "gitbranch"))
73
73
        os.chdir('gitbranch')
74
74
        builder = tests.GitBranchBuilder()
75
 
        builder.set_file('a', 'text for a\n', False)
76
 
        builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
 
75
        builder.set_file(b'a', b'text for a\n', False)
 
76
        builder.commit(b'Joe Foo <joe@foo.com>', b'<The commit message>')
77
77
        builder.finish()
78
78
        os.chdir('..')
79
79
 
80
80
        output, error = self.run_bzr(['branch', 'gitbranch', 'bzrbranch'])
81
81
        self.assertTrue(
82
 
            (error == 'Branched 1 revision(s).\n') or
83
 
            (error == 'Branched 1 revision.\n'),
 
82
            (error == b'Branched 1 revision(s).\n') or
 
83
            (error == b'Branched 1 revision.\n'),
84
84
            error)
85
85
 
86
86
    def test_checkout(self):
88
88
        GitRepo.init(os.path.join(self.test_dir, "gitbranch"))
89
89
        os.chdir('gitbranch')
90
90
        builder = tests.GitBranchBuilder()
91
 
        builder.set_file('a', 'text for a\n', False)
92
 
        builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
 
91
        builder.set_file(b'a', b'text for a\n', False)
 
92
        builder.commit(b'Joe Foo <joe@foo.com>', b'<The commit message>')
93
93
        builder.finish()
94
94
        os.chdir('..')
95
95
 
167
167
 
168
168
    def test_init_repo(self):
169
169
        output, error = self.run_bzr(["init", "--format=git", "bla.git"])
170
 
        self.assertEquals(error, '')
171
 
        self.assertEquals(output, 'Created a standalone tree (format: git)\n')
 
170
        self.assertEquals(error, b'')
 
171
        self.assertEquals(output, b'Created a standalone tree (format: git)\n')
172
172
 
173
173
    def test_diff_format(self):
174
174
        tree = self.make_branch_and_tree('.')
175
175
        self.build_tree(['a'])
176
176
        tree.add(['a'])
177
177
        output, error = self.run_bzr(['diff', '--format=git'], retcode=1)
178
 
        self.assertEqual(error, '')
 
178
        self.assertEqual(error, b'')
179
179
        self.assertEqual(output,
180
 
            'diff --git /dev/null b/a\n'
181
 
            'old mode 0\n'
182
 
            'new mode 100644\n'
183
 
            'index 0000000..c197bd8 100644\n'
184
 
            '--- /dev/null\n'
185
 
            '+++ b/a\n'
186
 
            '@@ -0,0 +1 @@\n'
187
 
            '+contents of a\n')
 
180
            b'diff --git /dev/null b/a\n'
 
181
            b'old mode 0\n'
 
182
            b'new mode 100644\n'
 
183
            b'index 0000000..c197bd8 100644\n'
 
184
            b'--- /dev/null\n'
 
185
            b'+++ b/a\n'
 
186
            b'@@ -0,0 +1 @@\n'
 
187
            b'+contents of a\n')
188
188
 
189
189
    def test_git_import_uncolocated(self):
190
190
        r = GitRepo.init("a", mkdir=True)
249
249
        cid = r.do_commit(ref="refs/heads/abranch", committer="Joe <joe@example.com>", message="Dummy")
250
250
        r["refs/tags/atag"] = cid
251
251
        (stdout, stderr) = self.run_bzr(["git-refs", "a"])
252
 
        self.assertEquals(stderr, "")
 
252
        self.assertEquals(stderr, b"")
253
253
        self.assertEquals(stdout,
254
 
            'refs/tags/atag -> ' + cid + '\n'
255
 
            'refs/heads/abranch -> ' + cid + '\n')
 
254
            b'refs/tags/atag -> ' + cid + b'\n'
 
255
            b'refs/heads/abranch -> ' + cid + b'\n')
256
256
 
257
257
    def test_git_refs_from_bzr(self):
258
258
        tree = self.make_branch_and_tree('a')
261
261
        revid = tree.commit(committer="Joe <joe@example.com>", message="Dummy")
262
262
        tree.branch.tags.set_tag("atag", revid)
263
263
        (stdout, stderr) = self.run_bzr(["git-refs", "a"])
264
 
        self.assertEquals(stderr, "")
265
 
        self.assertTrue("refs/tags/atag -> " in stdout)
266
 
        self.assertTrue("HEAD -> " in stdout)
 
264
        self.assertEquals(stderr, b"")
 
265
        self.assertTrue(b"refs/tags/atag -> " in stdout)
 
266
        self.assertTrue(b"HEAD -> " in stdout)
267
267
 
268
268
    def test_check(self):
269
269
        r = GitRepo.init("gitr", mkdir=True)
272
272
        r.do_commit("message", committer="Somebody <user@example.com>")
273
273
        out, err = self.run_bzr(["check", "gitr"])
274
274
        self.maxDiff = None
275
 
        self.assertMultiLineEqual(out, '')
276
 
        self.assertTrue(err.endswith, '3 objects\n')
 
275
        self.assertMultiLineEqual(out, b'')
 
276
        self.assertTrue(err.endswith, b'3 objects\n')