I almost got the test running with some additional fixes
(available at lp:~vila/loggerhead/export-tarball) only to run
into a bug in bzr itself (I think you should be able to fix that
one ;).
Note that your code requires bzr >= 2.4 (launchpad only runs
2.3.3 so far) so we'll need some support from the lp guys to
deploy a more recent version there.
Summary of my fixes:
- you need to create a branch (with some content even) before
being able to call
app = self.setUpLoggerhead()
So I've added a setUp method for your class to do that. You
probably want to add *more* tests to check that you get a valid
tarball with the expected content (which an empty branch
doesn't allow ;).
- you're calling get_export_generator without dest nor root and
the code in bzrlib defaults to dest to set root. This raises an
interesing point: which root should be used here (i.e. what do
we want to prefix all the paths in the archive
with). <project>-<branch nick>-<revno> may be nice (but ask
others for feedback too).
- you used '.tar.gz' for the format but bzr expects either 'tgz'
OR a dest file name to deduce the format from the file
suffix. I just used 'tgz' there.
With these fixes in place we get:
======================================================================
ERROR: bzrlib.plugins.loggerhead.loggerhead.tests.test_controllers.TestDownloadTarballUI.test_download_tarball
----------------------------------------------------------------------
_StringException: Text attachment: log
------------
0.622 creating repository in file:///tmp/testbzr-KY_qfE.tmp/bzrlib.plugins.loggerhead.loggerhead.tests.test_controllers.TestDownloadTarballUI.test_download_tarball/work/.bzr/.
0.624 creating branch <bzrlib.branch.BzrBranchFormat7 object at 0x22ae990> in file:///tmp/testbzr-KY_qfE.tmp/bzrlib.plugins.loggerhead.loggerhead.tests.test_controllers.TestDownloadTarballUI.test_download_tarball/work/
0.631 trying to create missing lock '/tmp/testbzr-KY_qfE.tmp/bzrlib.plugins.loggerhead.loggerhead.tests.test_controllers.TestDownloadTarballUI.test_download_tarball/work/.bzr/checkout/dirstate'
0.631 opening working tree '/tmp/testbzr-KY_qfE.tmp/bzrlib.plugins.loggerhead.loggerhead.tests.test_controllers.TestDownloadTarballUI.test_download_tarball/work'
0.642 export version <InventoryRevisionTree instance at 29ece90, rev_id='null:'>
0.649 opening working tree '/tmp/testbzr-KY_qfE.tmp'
------------
Text attachment: traceback
------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/testtools/runtest.py", line 169, in _run_user
return fn(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/testtools/testcase.py", line 499, in _run_test_method
return self._get_test_method()()
File "/home/vila/.bazaar/plugins/loggerhead/loggerhead/tests/test_controllers.py", line 140, in test_download_tarball
res = app.get('/tarball')
File "/usr/lib/pymodules/python2.7/paste/fixture.py", line 208, in get
return self.do_request(req, status=status)
File "/usr/lib/pymodules/python2.7/paste/fixture.py", line 389, in do_request
**req.environ)
File "/usr/lib/pymodules/python2.7/paste/wsgilib.py", line 346, in raw_interactive
for s in app_iter:
File "/usr/lib/pymodules/python2.7/paste/lint.py", line 265, in next
v = self.iterator.next()
File "/home/vila/.bazaar/plugins/loggerhead/loggerhead/exporter.py", line 43, in export_archive
for _ in get_export_generator(tree=tree, root=root, fileobj=fileobj, format=format):
File "/home/vila/src/bzr/trunk/bzrlib/export/__init__.py", line 129, in get_export_generator
force_mtime=force_mtime, fileobj=fileobj):
File "/home/vila/src/bzr/trunk/bzrlib/export/tar_exporter.py", line 155, in tgz_exporter_generator
zipstream = gzip.GzipFile(basename, 'w', fileobj=stream,
UnboundLocalError: local variable 'basename' referenced before assignment
------------
----------------------------------------------------------------------
Ran 44 tests in 1.933s
Hi,
I almost got the test running with some additional fixes
(available at lp:~vila/loggerhead/export-tarball) only to run
into a bug in bzr itself (I think you should be able to fix that
one ;).
Note that your code requires bzr >= 2.4 (launchpad only runs
2.3.3 so far) so we'll need some support from the lp guys to
deploy a more recent version there.
Summary of my fixes:
- you need to create a branch (with some content even) before
being able to call
app = self.setUpLogge rhead()
So I've added a setUp method for your class to do that. You
probably want to add *more* tests to check that you get a valid
tarball with the expected content (which an empty branch
doesn't allow ;).
- you're calling get_export_ generator without dest nor root and
the code in bzrlib defaults to dest to set root. This raises an
interesing point: which root should be used here (i.e. what do
we want to prefix all the paths in the archive
with). <project>-<branch nick>-<revno> may be nice (but ask
others for feedback too).
- you used '.tar.gz' for the format but bzr expects either 'tgz'
OR a dest file name to deduce the format from the file
suffix. I just used 'tgz' there.
With these fixes in place we get:
======= ======= ======= ======= ======= ======= ======= ======= ======= ======= plugins. loggerhead. loggerhead. tests.test_ controllers. TestDownloadTar ballUI. test_download_ tarball ------- ------- ------- ------- ------- ------- ------- ------- ------- /tmp/testbzr- KY_qfE. tmp/bzrlib. plugins. loggerhead. loggerhead. tests.test_ controllers. TestDownloadTar ballUI. test_download_ tarball/ work/.bzr/ . branch. BzrBranchFormat 7 object at 0x22ae990> in file:// /tmp/testbzr- KY_qfE. tmp/bzrlib. plugins. loggerhead. loggerhead. tests.test_ controllers. TestDownloadTar ballUI. test_download_ tarball/ work/ KY_qfE. tmp/bzrlib. plugins. loggerhead. loggerhead. tests.test_ controllers. TestDownloadTar ballUI. test_download_ tarball/ work/.bzr/ checkout/ dirstate' KY_qfE. tmp/bzrlib. plugins. loggerhead. loggerhead. tests.test_ controllers. TestDownloadTar ballUI. test_download_ tarball/ work' ionTree instance at 29ece90, rev_id='null:'> KY_qfE. tmp' python2. 7/dist- packages/ testtools/ runtest. py", line 169, in _run_user python2. 7/dist- packages/ testtools/ testcase. py", line 499, in _run_test_method test_method( )() vila/.bazaar/ plugins/ loggerhead/ loggerhead/ tests/test_ controllers. py", line 140, in test_download_ tarball pymodules/ python2. 7/paste/ fixture. py", line 208, in get request( req, status=status) pymodules/ python2. 7/paste/ fixture. py", line 389, in do_request pymodules/ python2. 7/paste/ wsgilib. py", line 346, in raw_interactive pymodules/ python2. 7/paste/ lint.py" , line 265, in next next() vila/.bazaar/ plugins/ loggerhead/ loggerhead/ exporter. py", line 43, in export_archive generator( tree=tree, root=root, fileobj=fileobj, format=format): vila/src/ bzr/trunk/ bzrlib/ export/ __init_ _.py", line 129, in get_export_ generator mtime=force_ mtime, fileobj=fileobj): vila/src/ bzr/trunk/ bzrlib/ export/ tar_exporter. py", line 155, in tgz_exporter_ generator basename, 'w', fileobj=stream,
ERROR: bzrlib.
-------
_StringException: Text attachment: log
------------
0.622 creating repository in file://
0.624 creating branch <bzrlib.
0.631 trying to create missing lock '/tmp/testbzr-
0.631 opening working tree '/tmp/testbzr-
0.642 export version <InventoryRevis
0.649 opening working tree '/tmp/testbzr-
------------
Text attachment: traceback
------------
Traceback (most recent call last):
File "/usr/lib/
return fn(*args, **kwargs)
File "/usr/lib/
return self._get_
File "/home/
res = app.get('/tarball')
File "/usr/lib/
return self.do_
File "/usr/lib/
**req.environ)
File "/usr/lib/
for s in app_iter:
File "/usr/lib/
v = self.iterator.
File "/home/
for _ in get_export_
File "/home/
force_
File "/home/
zipstream = gzip.GzipFile(
UnboundLocalError: local variable 'basename' referenced before assignment
------------
------- ------- ------- ------- ------- ------- ------- ------- ------- -------
Ran 44 tests in 1.933s
FAILED (errors=1)