Merge lp:~gz/bzr-builddeb/trivial_tweak_utf8_changelog_test into lp:bzr-builddeb

Proposed by Martin Packman
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 633
Merged at revision: 632
Proposed branch: lp:~gz/bzr-builddeb/trivial_tweak_utf8_changelog_test
Merge into: lp:bzr-builddeb
Diff against target: 25 lines (+8/-5)
1 file modified
tests/blackbox/test_builddeb.py (+8/-5)
To merge this branch: bzr merge lp:~gz/bzr-builddeb/trivial_tweak_utf8_changelog_test
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+79153@code.launchpad.net

This proposal supersedes a proposal from 2011-10-12.

Description of the change

Different approach to fixing test as suggested by Jelmer. We can't use debian.changelog because we want to support multiple versions and there's an incompatible change in how it handles non-ascii contents. Instead, just write something that looks vaguely like a changelog to disk for the test.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote : Posted in a previous version of this proposal

<jelmer_> mgz: still there
<jelmer_> mgz: ?
<jelmer_> mgz: With your patch, that test fails for me on oneiric
<jelmer_> mgz: I wonder if we should just open('debian/changelog', 'w').write("""...""") to make things simpler

Revision history for this message
Jelmer Vernooij (jelmer) wrote : Posted in a previous version of this proposal

======================================================================
ERROR: bzrlib.plugins.builddeb.tests.blackbox.test_builddeb.TestBuilddeb.test_utf8_changelog
----------------------------------------------------------------------
_StringException: log: {{{
3.585 creating repository in file:///tmp/testbzr-p9_cJ_.tmp/bzrlib.plugins.builddeb.tests.blackbox.test_builddeb.TestBuilddeb.test_utf8_changelog/work/.bzr/.
3.588 creating branch <bzrlib.branch.BzrBranchFormat7 object at 0x3d83790> in file:///tmp/testbzr-p9_cJ_.tmp/bzrlib.plugins.builddeb.tests.blackbox.test_builddeb.TestBuilddeb.test_utf8_changelog/work/
3.597 trying to create missing lock '/tmp/testbzr-p9_cJ_.tmp/bzrlib.plugins.builddeb.tests.blackbox.test_builddeb.TestBuilddeb.test_utf8_changelog/work/.bzr/checkout/dirstate'
3.598 opening working tree '/tmp/testbzr-p9_cJ_.tmp/bzrlib.plugins.builddeb.tests.blackbox.test_builddeb.TestBuilddeb.test_utf8_changelog/work'
3.610 preparing to commit
    INFO Committing to: /tmp/testbzr-p9_cJ_.tmp/bzrlib.plugins.builddeb.tests.blackbox.test_builddeb.TestBuilddeb.test_utf8_changelog/work/
3.613 Selecting files for commit with filter None
    INFO added README
    INFO added debian
    INFO added debian/changelog
    INFO Committed revision 1.
3.624 Committed revid prerel as revno 1.
}}}

Traceback (most recent call last):
  File "/home/jelmer/src/bzr-builddeb/trunk/tests/blackbox/test_builddeb.py", line 189, in test_utf8_changelog
    self.write_changelog(c, "debian/changelog")
  File "/home/jelmer/src/bzr-builddeb/trunk/tests/__init__.py", line 216, in write_changelog
    changelog.write_to_open_file(f)
  File "/usr/lib/python2.7/dist-packages/debian/changelog.py", line 505, in write_to_open_file
    file.write(self.__str__())
  File "/usr/lib/python2.7/dist-packages/debian/changelog.py", line 470, in __str__
    return unicode(self).encode(self._encoding)
  File "/usr/lib/python2.7/dist-packages/debian/changelog.py", line 466, in __unicode__
    pieces.append(unicode(block))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 57: ordinal not in range(128)

----------------------------------------------------------------------

Revision history for this message
Martin Packman (gz) wrote : Posted in a previous version of this proposal

Thanks for testing that Jelmer. Annoying, by fiddling across different versions debian.changelog can't reliably be used with non-ascii contents. I'll look at just splatting some bytes as you suggest.

Revision history for this message
Martin Packman (gz) wrote : Posted in a previous version of this proposal

Whoops, push had remembered the wrong place, ignore this mp.

Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/blackbox/test_builddeb.py'
2--- tests/blackbox/test_builddeb.py 2011-10-01 20:41:14 +0000
3+++ tests/blackbox/test_builddeb.py 2011-10-12 16:45:28 +0000
4@@ -183,13 +183,16 @@
5 # is then changed, so need to clear it, commit, then set the contents.
6 open("debian/changelog", "w").close()
7 tree.commit("Prepare for release", rev_id="prerel")
8- c = self.make_changelog()
9- c.add_change(u"")
10- c.add_change(u" * \u2026and another thing")
11- self.write_changelog(c, "debian/changelog")
12+ # Would be nice to use debian.changelog to make one, but it's changed
13+ # across versions as to how it wants non-ascii bytes provided.
14+ f = open("debian/changelog", "w")
15+ try:
16+ f.write(" * \xe2\x80\xa6and another thing")
17+ finally:
18+ f.close()
19 self.run_bzr(['commit'])
20 branch = tree.branch
21- self.assertEqual(u"* test build\n* \u2026and another thing\n",
22+ self.assertEqual(u"\u2026and another thing",
23 branch.repository.get_revision(branch.last_revision()).message)
24
25 # vim: ts=2 sts=2 sw=2

Subscribers

People subscribed via source and target branches