~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_weave.py

  • Committer: Jelmer Vernooij
  • Date: 2011-01-14 00:58:16 UTC
  • mto: (5582.12.2 weave-plugin)
  • mto: This revision was merged to the branch mainline in revision 5718.
  • Revision ID: jelmer@samba.org-20110114005816-b3g5xigfiy20s29y
Fix imports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005-2009, 2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
27
27
    errors,
28
28
    )
29
29
from bzrlib.osutils import sha_string
30
 
from bzrlib.tests import TestCase, TestCaseInTempDir
31
 
from bzrlib.weave import Weave, WeaveFormatError, WeaveError
32
 
from bzrlib.weavefile import write_weave, read_weave
 
30
from bzrlib.tests import (
 
31
    TestCase,
 
32
    TestCaseInTempDir,
 
33
    )
 
34
from bzrlib.weave import (
 
35
    Weave,
 
36
    WeaveFormatError,
 
37
    )
 
38
from bzrlib.plugins.weave_fmt.weavefile import (
 
39
    write_weave,
 
40
    read_weave,
 
41
    )
33
42
 
34
43
 
35
44
# texts for use in testing
689
698
        w = read_weave(tmpf)
690
699
 
691
700
        self.assertEqual('hello\n', w.get_text('v1'))
692
 
        self.assertRaises(errors.WeaveInvalidChecksum, w.get_text, 'v2')
693
 
        self.assertRaises(errors.WeaveInvalidChecksum, w.get_lines, 'v2')
694
 
        self.assertRaises(errors.WeaveInvalidChecksum, w.check)
 
701
        self.assertRaises(errors.VersionedFileInvalidChecksum, w.get_text, 'v2')
 
702
        self.assertRaises(errors.VersionedFileInvalidChecksum, w.get_lines, 'v2')
 
703
        self.assertRaises(errors.VersionedFileInvalidChecksum, w.check)
695
704
 
696
705
        # Change the sha checksum
697
706
        tmpf = StringIO('# bzr weave file v5\n'
702
711
        w = read_weave(tmpf)
703
712
 
704
713
        self.assertEqual('hello\n', w.get_text('v1'))
705
 
        self.assertRaises(errors.WeaveInvalidChecksum, w.get_text, 'v2')
706
 
        self.assertRaises(errors.WeaveInvalidChecksum, w.get_lines, 'v2')
707
 
        self.assertRaises(errors.WeaveInvalidChecksum, w.check)
 
714
        self.assertRaises(errors.VersionedFileInvalidChecksum, w.get_text, 'v2')
 
715
        self.assertRaises(errors.VersionedFileInvalidChecksum, w.get_lines, 'v2')
 
716
        self.assertRaises(errors.VersionedFileInvalidChecksum, w.check)
708
717
 
709
718
 
710
719
class TestWeave(TestCase):
757
766
    def test_empty_file(self):
758
767
        f = open('empty.weave', 'wb+')
759
768
        try:
760
 
            self.assertRaises(errors.WeaveFormatError,
761
 
                              read_weave, f)
 
769
            self.assertRaises(WeaveFormatError, read_weave, f)
762
770
        finally:
763
771
            f.close()