test_client.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. # test_client.py -- Tests for the git protocol, client side
  2. # Copyright (C) 2009 Jelmer Vernooij <jelmer@samba.org>
  3. #
  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. # or (at your option) any later version of the License.
  8. #
  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.
  13. #
  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,
  17. # MA 02110-1301, USA.
  18. from io import BytesIO
  19. from dulwich import (
  20. client,
  21. )
  22. from dulwich.client import (
  23. LocalGitClient,
  24. TraditionalGitClient,
  25. TCPGitClient,
  26. SubprocessGitClient,
  27. SSHGitClient,
  28. HttpGitClient,
  29. ReportStatusParser,
  30. SendPackError,
  31. UpdateRefsError,
  32. get_transport_and_path,
  33. get_transport_and_path_from_url,
  34. )
  35. from dulwich.tests import (
  36. TestCase,
  37. )
  38. from dulwich.protocol import (
  39. TCP_GIT_PORT,
  40. Protocol,
  41. )
  42. from dulwich.pack import (
  43. write_pack_objects,
  44. )
  45. from dulwich.objects import (
  46. Commit,
  47. Tree
  48. )
  49. from dulwich.repo import MemoryRepo
  50. from dulwich.tests.utils import (
  51. open_repo,
  52. )
  53. class DummyClient(TraditionalGitClient):
  54. def __init__(self, can_read, read, write):
  55. self.can_read = can_read
  56. self.read = read
  57. self.write = write
  58. TraditionalGitClient.__init__(self)
  59. def _connect(self, service, path):
  60. return Protocol(self.read, self.write), self.can_read
  61. # TODO(durin42): add unit-level tests of GitClient
  62. class GitClientTests(TestCase):
  63. def setUp(self):
  64. super(GitClientTests, self).setUp()
  65. self.rout = BytesIO()
  66. self.rin = BytesIO()
  67. self.client = DummyClient(lambda x: True, self.rin.read,
  68. self.rout.write)
  69. def test_caps(self):
  70. self.assertEqual(set(['multi_ack', 'side-band-64k', 'ofs-delta',
  71. 'thin-pack', 'multi_ack_detailed']),
  72. set(self.client._fetch_capabilities))
  73. self.assertEqual(set(['ofs-delta', 'report-status', 'side-band-64k']),
  74. set(self.client._send_capabilities))
  75. def test_archive_ack(self):
  76. self.rin.write(
  77. '0009NACK\n'
  78. '0000')
  79. self.rin.seek(0)
  80. self.client.archive('bla', 'HEAD', None, None)
  81. self.assertEqual(self.rout.getvalue(), '0011argument HEAD0000')
  82. def test_fetch_empty(self):
  83. self.rin.write('0000')
  84. self.rin.seek(0)
  85. self.client.fetch_pack('/', lambda heads: [], None, None)
  86. def test_fetch_pack_none(self):
  87. self.rin.write(
  88. '008855dcc6bf963f922e1ed5c4bbaaefcfacef57b1d7 HEAD.multi_ack '
  89. 'thin-pack side-band side-band-64k ofs-delta shallow no-progress '
  90. 'include-tag\n'
  91. '0000')
  92. self.rin.seek(0)
  93. self.client.fetch_pack('bla', lambda heads: [], None, None, None)
  94. self.assertEqual(self.rout.getvalue(), '0000')
  95. def test_send_pack_no_sideband64k_with_update_ref_error(self):
  96. # No side-bank-64k reported by server shouldn't try to parse
  97. # side band data
  98. pkts = ['55dcc6bf963f922e1ed5c4bbaaefcfacef57b1d7 capabilities^{}'
  99. '\x00 report-status delete-refs ofs-delta\n',
  100. '',
  101. "unpack ok",
  102. "ng refs/foo/bar pre-receive hook declined",
  103. '']
  104. for pkt in pkts:
  105. if pkt == '':
  106. self.rin.write("0000")
  107. else:
  108. self.rin.write("%04x%s" % (len(pkt)+4, pkt))
  109. self.rin.seek(0)
  110. tree = Tree()
  111. commit = Commit()
  112. commit.tree = tree
  113. commit.parents = []
  114. commit.author = commit.committer = 'test user'
  115. commit.commit_time = commit.author_time = 1174773719
  116. commit.commit_timezone = commit.author_timezone = 0
  117. commit.encoding = 'UTF-8'
  118. commit.message = 'test message'
  119. def determine_wants(refs):
  120. return {'refs/foo/bar': commit.id, }
  121. def generate_pack_contents(have, want):
  122. return [(commit, None), (tree, ''), ]
  123. self.assertRaises(UpdateRefsError,
  124. self.client.send_pack, "blah",
  125. determine_wants, generate_pack_contents)
  126. def test_send_pack_none(self):
  127. self.rin.write(
  128. '0078310ca9477129b8586fa2afc779c1f57cf64bba6c '
  129. 'refs/heads/master\x00 report-status delete-refs '
  130. 'side-band-64k quiet ofs-delta\n'
  131. '0000')
  132. self.rin.seek(0)
  133. def determine_wants(refs):
  134. return {
  135. 'refs/heads/master': '310ca9477129b8586fa2afc779c1f57cf64bba6c'
  136. }
  137. def generate_pack_contents(have, want):
  138. return {}
  139. self.client.send_pack('/', determine_wants, generate_pack_contents)
  140. self.assertEqual(self.rout.getvalue(), '0000')
  141. def test_send_pack_delete_only(self):
  142. self.rin.write(
  143. '0063310ca9477129b8586fa2afc779c1f57cf64bba6c '
  144. 'refs/heads/master\x00report-status delete-refs ofs-delta\n'
  145. '0000000eunpack ok\n'
  146. '0019ok refs/heads/master\n'
  147. '0000')
  148. self.rin.seek(0)
  149. def determine_wants(refs):
  150. return {'refs/heads/master': '0' * 40}
  151. def generate_pack_contents(have, want):
  152. return {}
  153. self.client.send_pack('/', determine_wants, generate_pack_contents)
  154. self.assertIn(
  155. self.rout.getvalue(),
  156. ['007f310ca9477129b8586fa2afc779c1f57cf64bba6c '
  157. '0000000000000000000000000000000000000000 '
  158. 'refs/heads/master\x00report-status ofs-delta0000',
  159. '007f310ca9477129b8586fa2afc779c1f57cf64bba6c '
  160. '0000000000000000000000000000000000000000 '
  161. 'refs/heads/master\x00ofs-delta report-status0000'])
  162. def test_send_pack_new_ref_only(self):
  163. self.rin.write(
  164. '0063310ca9477129b8586fa2afc779c1f57cf64bba6c '
  165. 'refs/heads/master\x00report-status delete-refs ofs-delta\n'
  166. '0000000eunpack ok\n'
  167. '0019ok refs/heads/blah12\n'
  168. '0000')
  169. self.rin.seek(0)
  170. def determine_wants(refs):
  171. return {
  172. 'refs/heads/blah12':
  173. '310ca9477129b8586fa2afc779c1f57cf64bba6c',
  174. 'refs/heads/master': '310ca9477129b8586fa2afc779c1f57cf64bba6c'
  175. }
  176. def generate_pack_contents(have, want):
  177. return {}
  178. f = BytesIO()
  179. write_pack_objects(f, {})
  180. self.client.send_pack('/', determine_wants, generate_pack_contents)
  181. self.assertIn(
  182. self.rout.getvalue(),
  183. ['007f0000000000000000000000000000000000000000 '
  184. '310ca9477129b8586fa2afc779c1f57cf64bba6c '
  185. 'refs/heads/blah12\x00report-status ofs-delta0000%s'
  186. % f.getvalue(),
  187. '007f0000000000000000000000000000000000000000 '
  188. '310ca9477129b8586fa2afc779c1f57cf64bba6c '
  189. 'refs/heads/blah12\x00ofs-delta report-status0000%s'
  190. % f.getvalue()])
  191. def test_send_pack_new_ref(self):
  192. self.rin.write(
  193. '0064310ca9477129b8586fa2afc779c1f57cf64bba6c '
  194. 'refs/heads/master\x00 report-status delete-refs ofs-delta\n'
  195. '0000000eunpack ok\n'
  196. '0019ok refs/heads/blah12\n'
  197. '0000')
  198. self.rin.seek(0)
  199. tree = Tree()
  200. commit = Commit()
  201. commit.tree = tree
  202. commit.parents = []
  203. commit.author = commit.committer = 'test user'
  204. commit.commit_time = commit.author_time = 1174773719
  205. commit.commit_timezone = commit.author_timezone = 0
  206. commit.encoding = 'UTF-8'
  207. commit.message = 'test message'
  208. def determine_wants(refs):
  209. return {
  210. 'refs/heads/blah12': commit.id,
  211. 'refs/heads/master': '310ca9477129b8586fa2afc779c1f57cf64bba6c'
  212. }
  213. def generate_pack_contents(have, want):
  214. return [(commit, None), (tree, ''), ]
  215. f = BytesIO()
  216. write_pack_objects(f, generate_pack_contents(None, None))
  217. self.client.send_pack('/', determine_wants, generate_pack_contents)
  218. self.assertIn(
  219. self.rout.getvalue(),
  220. ['007f0000000000000000000000000000000000000000 %s '
  221. 'refs/heads/blah12\x00report-status ofs-delta0000%s'
  222. % (commit.id, f.getvalue()),
  223. '007f0000000000000000000000000000000000000000 %s '
  224. 'refs/heads/blah12\x00ofs-delta report-status0000%s'
  225. % (commit.id, f.getvalue())])
  226. def test_send_pack_no_deleteref_delete_only(self):
  227. pkts = ['310ca9477129b8586fa2afc779c1f57cf64bba6c refs/heads/master'
  228. '\x00 report-status ofs-delta\n',
  229. '',
  230. '']
  231. for pkt in pkts:
  232. if pkt == '':
  233. self.rin.write("0000")
  234. else:
  235. self.rin.write("%04x%s" % (len(pkt)+4, pkt))
  236. self.rin.seek(0)
  237. def determine_wants(refs):
  238. return {'refs/heads/master': '0' * 40}
  239. def generate_pack_contents(have, want):
  240. return {}
  241. self.assertRaises(UpdateRefsError,
  242. self.client.send_pack, "/",
  243. determine_wants, generate_pack_contents)
  244. self.assertEqual(self.rout.getvalue(), '0000')
  245. class TestGetTransportAndPath(TestCase):
  246. def test_tcp(self):
  247. c, path = get_transport_and_path('git://foo.com/bar/baz')
  248. self.assertTrue(isinstance(c, TCPGitClient))
  249. self.assertEqual('foo.com', c._host)
  250. self.assertEqual(TCP_GIT_PORT, c._port)
  251. self.assertEqual('/bar/baz', path)
  252. def test_tcp_port(self):
  253. c, path = get_transport_and_path('git://foo.com:1234/bar/baz')
  254. self.assertTrue(isinstance(c, TCPGitClient))
  255. self.assertEqual('foo.com', c._host)
  256. self.assertEqual(1234, c._port)
  257. self.assertEqual('/bar/baz', path)
  258. def test_ssh_explicit(self):
  259. c, path = get_transport_and_path('git+ssh://foo.com/bar/baz')
  260. self.assertTrue(isinstance(c, SSHGitClient))
  261. self.assertEqual('foo.com', c.host)
  262. self.assertEqual(None, c.port)
  263. self.assertEqual(None, c.username)
  264. self.assertEqual('bar/baz', path)
  265. def test_ssh_port_explicit(self):
  266. c, path = get_transport_and_path(
  267. 'git+ssh://foo.com:1234/bar/baz')
  268. self.assertTrue(isinstance(c, SSHGitClient))
  269. self.assertEqual('foo.com', c.host)
  270. self.assertEqual(1234, c.port)
  271. self.assertEqual('bar/baz', path)
  272. def test_ssh_abspath_explicit(self):
  273. c, path = get_transport_and_path('git+ssh://foo.com//bar/baz')
  274. self.assertTrue(isinstance(c, SSHGitClient))
  275. self.assertEqual('foo.com', c.host)
  276. self.assertEqual(None, c.port)
  277. self.assertEqual(None, c.username)
  278. self.assertEqual('/bar/baz', path)
  279. def test_ssh_port_abspath_explicit(self):
  280. c, path = get_transport_and_path(
  281. 'git+ssh://foo.com:1234//bar/baz')
  282. self.assertTrue(isinstance(c, SSHGitClient))
  283. self.assertEqual('foo.com', c.host)
  284. self.assertEqual(1234, c.port)
  285. self.assertEqual('/bar/baz', path)
  286. def test_ssh_implicit(self):
  287. c, path = get_transport_and_path('foo:/bar/baz')
  288. self.assertTrue(isinstance(c, SSHGitClient))
  289. self.assertEqual('foo', c.host)
  290. self.assertEqual(None, c.port)
  291. self.assertEqual(None, c.username)
  292. self.assertEqual('/bar/baz', path)
  293. def test_ssh_host(self):
  294. c, path = get_transport_and_path('foo.com:/bar/baz')
  295. self.assertTrue(isinstance(c, SSHGitClient))
  296. self.assertEqual('foo.com', c.host)
  297. self.assertEqual(None, c.port)
  298. self.assertEqual(None, c.username)
  299. self.assertEqual('/bar/baz', path)
  300. def test_ssh_user_host(self):
  301. c, path = get_transport_and_path('user@foo.com:/bar/baz')
  302. self.assertTrue(isinstance(c, SSHGitClient))
  303. self.assertEqual('foo.com', c.host)
  304. self.assertEqual(None, c.port)
  305. self.assertEqual('user', c.username)
  306. self.assertEqual('/bar/baz', path)
  307. def test_ssh_relpath(self):
  308. c, path = get_transport_and_path('foo:bar/baz')
  309. self.assertTrue(isinstance(c, SSHGitClient))
  310. self.assertEqual('foo', c.host)
  311. self.assertEqual(None, c.port)
  312. self.assertEqual(None, c.username)
  313. self.assertEqual('bar/baz', path)
  314. def test_ssh_host_relpath(self):
  315. c, path = get_transport_and_path('foo.com:bar/baz')
  316. self.assertTrue(isinstance(c, SSHGitClient))
  317. self.assertEqual('foo.com', c.host)
  318. self.assertEqual(None, c.port)
  319. self.assertEqual(None, c.username)
  320. self.assertEqual('bar/baz', path)
  321. def test_ssh_user_host_relpath(self):
  322. c, path = get_transport_and_path('user@foo.com:bar/baz')
  323. self.assertTrue(isinstance(c, SSHGitClient))
  324. self.assertEqual('foo.com', c.host)
  325. self.assertEqual(None, c.port)
  326. self.assertEqual('user', c.username)
  327. self.assertEqual('bar/baz', path)
  328. def test_subprocess(self):
  329. c, path = get_transport_and_path('foo.bar/baz')
  330. self.assertTrue(isinstance(c, SubprocessGitClient))
  331. self.assertEqual('foo.bar/baz', path)
  332. def test_error(self):
  333. # Need to use a known urlparse.uses_netloc URL scheme to get the
  334. # expected parsing of the URL on Python versions less than 2.6.5
  335. c, path = get_transport_and_path('prospero://bar/baz')
  336. self.assertTrue(isinstance(c, SSHGitClient))
  337. def test_http(self):
  338. url = 'https://github.com/jelmer/dulwich'
  339. c, path = get_transport_and_path(url)
  340. self.assertTrue(isinstance(c, HttpGitClient))
  341. self.assertEqual('/jelmer/dulwich', path)
  342. class TestGetTransportAndPathFromUrl(TestCase):
  343. def test_tcp(self):
  344. c, path = get_transport_and_path_from_url('git://foo.com/bar/baz')
  345. self.assertTrue(isinstance(c, TCPGitClient))
  346. self.assertEqual('foo.com', c._host)
  347. self.assertEqual(TCP_GIT_PORT, c._port)
  348. self.assertEqual('/bar/baz', path)
  349. def test_tcp_port(self):
  350. c, path = get_transport_and_path_from_url('git://foo.com:1234/bar/baz')
  351. self.assertTrue(isinstance(c, TCPGitClient))
  352. self.assertEqual('foo.com', c._host)
  353. self.assertEqual(1234, c._port)
  354. self.assertEqual('/bar/baz', path)
  355. def test_ssh_explicit(self):
  356. c, path = get_transport_and_path_from_url('git+ssh://foo.com/bar/baz')
  357. self.assertTrue(isinstance(c, SSHGitClient))
  358. self.assertEqual('foo.com', c.host)
  359. self.assertEqual(None, c.port)
  360. self.assertEqual(None, c.username)
  361. self.assertEqual('bar/baz', path)
  362. def test_ssh_port_explicit(self):
  363. c, path = get_transport_and_path_from_url(
  364. 'git+ssh://foo.com:1234/bar/baz')
  365. self.assertTrue(isinstance(c, SSHGitClient))
  366. self.assertEqual('foo.com', c.host)
  367. self.assertEqual(1234, c.port)
  368. self.assertEqual('bar/baz', path)
  369. def test_ssh_abspath_explicit(self):
  370. c, path = get_transport_and_path_from_url('git+ssh://foo.com//bar/baz')
  371. self.assertTrue(isinstance(c, SSHGitClient))
  372. self.assertEqual('foo.com', c.host)
  373. self.assertEqual(None, c.port)
  374. self.assertEqual(None, c.username)
  375. self.assertEqual('/bar/baz', path)
  376. def test_ssh_port_abspath_explicit(self):
  377. c, path = get_transport_and_path_from_url(
  378. 'git+ssh://foo.com:1234//bar/baz')
  379. self.assertTrue(isinstance(c, SSHGitClient))
  380. self.assertEqual('foo.com', c.host)
  381. self.assertEqual(1234, c.port)
  382. self.assertEqual('/bar/baz', path)
  383. def test_ssh_host_relpath(self):
  384. self.assertRaises(ValueError, get_transport_and_path_from_url,
  385. 'foo.com:bar/baz')
  386. def test_ssh_user_host_relpath(self):
  387. self.assertRaises(ValueError, get_transport_and_path_from_url,
  388. 'user@foo.com:bar/baz')
  389. def test_local_path(self):
  390. self.assertRaises(ValueError, get_transport_and_path_from_url,
  391. 'foo.bar/baz')
  392. def test_error(self):
  393. # Need to use a known urlparse.uses_netloc URL scheme to get the
  394. # expected parsing of the URL on Python versions less than 2.6.5
  395. self.assertRaises(ValueError, get_transport_and_path_from_url,
  396. 'prospero://bar/baz')
  397. def test_http(self):
  398. url = 'https://github.com/jelmer/dulwich'
  399. c, path = get_transport_and_path_from_url(url)
  400. self.assertTrue(isinstance(c, HttpGitClient))
  401. self.assertEqual('/jelmer/dulwich', path)
  402. def test_file(self):
  403. c, path = get_transport_and_path_from_url('file:///home/jelmer/foo')
  404. self.assertTrue(isinstance(c, SubprocessGitClient))
  405. self.assertEqual('/home/jelmer/foo', path)
  406. class TestSSHVendor(object):
  407. def __init__(self):
  408. self.host = None
  409. self.command = ""
  410. self.username = None
  411. self.port = None
  412. def run_command(self, host, command, username=None, port=None):
  413. self.host = host
  414. self.command = command
  415. self.username = username
  416. self.port = port
  417. class Subprocess: pass
  418. setattr(Subprocess, 'read', lambda: None)
  419. setattr(Subprocess, 'write', lambda: None)
  420. setattr(Subprocess, 'close', lambda: None)
  421. setattr(Subprocess, 'can_read', lambda: None)
  422. return Subprocess()
  423. class SSHGitClientTests(TestCase):
  424. def setUp(self):
  425. super(SSHGitClientTests, self).setUp()
  426. self.server = TestSSHVendor()
  427. self.real_vendor = client.get_ssh_vendor
  428. client.get_ssh_vendor = lambda: self.server
  429. self.client = SSHGitClient('git.samba.org')
  430. def tearDown(self):
  431. super(SSHGitClientTests, self).tearDown()
  432. client.get_ssh_vendor = self.real_vendor
  433. def test_default_command(self):
  434. self.assertEqual('git-upload-pack',
  435. self.client._get_cmd_path('upload-pack'))
  436. def test_alternative_command_path(self):
  437. self.client.alternative_paths['upload-pack'] = (
  438. '/usr/lib/git/git-upload-pack')
  439. self.assertEqual('/usr/lib/git/git-upload-pack',
  440. self.client._get_cmd_path('upload-pack'))
  441. def test_connect(self):
  442. server = self.server
  443. client = self.client
  444. client.username = "username"
  445. client.port = 1337
  446. client._connect("command", "/path/to/repo")
  447. self.assertEqual("username", server.username)
  448. self.assertEqual(1337, server.port)
  449. self.assertEqual(["git-command '/path/to/repo'"], server.command)
  450. client._connect("relative-command", "/~/path/to/repo")
  451. self.assertEqual(["git-relative-command '~/path/to/repo'"],
  452. server.command)
  453. class ReportStatusParserTests(TestCase):
  454. def test_invalid_pack(self):
  455. parser = ReportStatusParser()
  456. parser.handle_packet("unpack error - foo bar")
  457. parser.handle_packet("ok refs/foo/bar")
  458. parser.handle_packet(None)
  459. self.assertRaises(SendPackError, parser.check)
  460. def test_update_refs_error(self):
  461. parser = ReportStatusParser()
  462. parser.handle_packet("unpack ok")
  463. parser.handle_packet("ng refs/foo/bar need to pull")
  464. parser.handle_packet(None)
  465. self.assertRaises(UpdateRefsError, parser.check)
  466. def test_ok(self):
  467. parser = ReportStatusParser()
  468. parser.handle_packet("unpack ok")
  469. parser.handle_packet("ok refs/foo/bar")
  470. parser.handle_packet(None)
  471. parser.check()
  472. class LocalGitClientTests(TestCase):
  473. def test_fetch_into_empty(self):
  474. c = LocalGitClient()
  475. t = MemoryRepo()
  476. s = open_repo('a.git')
  477. self.assertEqual(s.get_refs(), c.fetch(s.path, t))
  478. def test_fetch_empty(self):
  479. c = LocalGitClient()
  480. s = open_repo('a.git')
  481. out = BytesIO()
  482. walker = {}
  483. c.fetch_pack(s.path, lambda heads: [], graph_walker=walker,
  484. pack_data=out.write)
  485. self.assertEqual("PACK\x00\x00\x00\x02\x00\x00\x00\x00\x02\x9d\x08"
  486. "\x82;\xd8\xa8\xea\xb5\x10\xadj\xc7\\\x82<\xfd>\xd3\x1e", out.getvalue())
  487. def test_fetch_pack_none(self):
  488. c = LocalGitClient()
  489. s = open_repo('a.git')
  490. out = BytesIO()
  491. walker = MemoryRepo().get_graph_walker()
  492. c.fetch_pack(s.path,
  493. lambda heads: ["a90fa2d900a17e99b433217e988c4eb4a2e9a097"],
  494. graph_walker=walker, pack_data=out.write)
  495. # Hardcoding is not ideal, but we'll fix that some other day..
  496. self.assertTrue(out.getvalue().startswith('PACK\x00\x00\x00\x02\x00\x00\x00\x07'))