1 # test_patch.py -- tests for patch.py
2 # Copryight (C) 2010 Jelmer Vernooij <jelmer@samba.org>
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; version 2
7 # of the License or (at your option) a later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 """Tests for patch.py."""
21 from cStringIO import StringIO
22 from unittest import TestCase
24 from dulwich.objects import (
28 from dulwich.patch import (
33 class WriteCommitPatchTests(TestCase):
35 def test_simple(self):
38 c.committer = c.author = "Jelmer <jelmer@samba.org>"
39 c.commit_time = c.author_time = 1271350201
40 c.commit_timezone = c.author_timezone = 0
41 c.message = "This is the first line\nAnd this is the second line.\n"
43 write_commit_patch(f, c, "CONTENTS", (1, 1), version="custom")
46 self.assertTrue(lines[0].startswith("From 0b0d34d1b5b596c928adc9a727a4b9e03d025298"))
47 self.assertEquals(lines[1], "From: Jelmer <jelmer@samba.org>\n")
48 self.assertTrue(lines[2].startswith("Date: "))
50 "Subject: [PATCH 1/1] This is the first line\n",
51 "And this is the second line.\n",
58 "custom\n"], lines[-3:])
60 # diffstat may not be present
61 self.assertEquals(lines[8], " 0 files changed\n")