~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockable_files.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-05-02 14:08:26 UTC
  • mfrom: (3388.2.3 controlfiles)
  • Revision ID: pqm@pqm.ubuntu.com-20080502140826-nhg73h31i9viu175
(mbp) deprecate LocableFiles.get_utf8

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2008 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
24
24
    )
25
25
from bzrlib.errors import BzrBadParameterNotString, NoSuchFile, ReadOnlyError
26
26
from bzrlib.lockable_files import LockableFiles, TransportLock
 
27
from bzrlib.symbol_versioning import (
 
28
    deprecated_in,
 
29
    )
27
30
from bzrlib.tests import TestCaseInTempDir
28
31
from bzrlib.tests.test_smart import TestCaseWithSmartMedium
29
32
from bzrlib.tests.test_transactions import DummyWeave
35
38
 
36
39
 
37
40
# these tests are applied in each parameterized suite for LockableFiles
 
41
#
 
42
# they use an old style of parameterization, but we want to remove this class
 
43
# so won't modernize them now. - mbp 20080430
38
44
class _TestLockableFiles_mixin(object):
39
45
 
40
46
    def test_read_write(self):
41
47
        self.assertRaises(NoSuchFile, self.lockable.get, 'foo')
42
 
        self.assertRaises(NoSuchFile, self.lockable.get_utf8, 'foo')
 
48
        self.assertRaises(NoSuchFile,
 
49
            self.applyDeprecated,
 
50
            deprecated_in((1, 5, 0)),
 
51
            self.lockable.get_utf8, 'foo')
43
52
        self.lockable.lock_write()
44
53
        try:
45
54
            unicode_string = u'bar\u1234'
51
60
            self.lockable.put('foo', StringIO(byte_string))
52
61
            self.assertEqual(byte_string,
53
62
                             self.lockable.get('foo').read())
 
63
            unicode_stream = self.applyDeprecated(
 
64
                deprecated_in((1, 5, 0)),
 
65
                self.lockable.get_utf8,
 
66
                'foo')
54
67
            self.assertEqual(unicode_string,
55
 
                             self.lockable.get_utf8('foo').read())
 
68
                unicode_stream.read())
56
69
            self.assertRaises(BzrBadParameterNotString,
57
70
                              self.lockable.put_utf8,
58
71
                              'bar',
59
72
                              StringIO(unicode_string)
60
73
                              )
61
74
            self.lockable.put_utf8('bar', unicode_string)
 
75
            unicode_stream = self.applyDeprecated(
 
76
                deprecated_in((1, 5, 0)),
 
77
                self.lockable.get_utf8,
 
78
                'bar')
62
79
            self.assertEqual(unicode_string,
63
 
                             self.lockable.get_utf8('bar').read())
 
80
                unicode_stream.read())
64
81
            self.assertEqual(byte_string,
65
82
                             self.lockable.get('bar').read())
66
83
            self.lockable.put_bytes('raw', 'raw\xffbytes')