equal
deleted
inserted
replaced
|
1 # copyright 2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
3 # |
|
4 # This file is part of CubicWeb. |
|
5 # |
|
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
|
7 # terms of the GNU Lesser General Public License as published by the Free |
|
8 # Software Foundation, either version 2.1 of the License, or (at your option) |
|
9 # any later version. |
|
10 # |
|
11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
|
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
|
14 # details. |
|
15 # |
|
16 # You should have received a copy of the GNU Lesser General Public License along |
|
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
|
18 |
|
19 from unittest import TestCase |
|
20 import os.path as osp |
|
21 import pickle |
|
22 |
1 from six import PY2 |
23 from six import PY2 |
2 |
24 |
3 from unittest import TestCase |
25 from logilab.common.shellutils import tempdir |
4 from tempfile import NamedTemporaryFile |
|
5 import os.path as osp |
|
6 |
26 |
7 from logilab.common.shellutils import tempdir |
|
8 from cubicweb import Binary |
27 from cubicweb import Binary |
9 |
28 |
10 |
29 |
11 class BinaryTC(TestCase): |
30 class BinaryTC(TestCase): |
12 def test_init(self): |
31 def test_init(self): |
46 Binary(b'binaryblob').to_file(fobj) |
65 Binary(b'binaryblob').to_file(fobj) |
47 |
66 |
48 bobj = Binary.from_file(fpath) |
67 bobj = Binary.from_file(fpath) |
49 self.assertEqual(bobj.getvalue(), b'binaryblob') |
68 self.assertEqual(bobj.getvalue(), b'binaryblob') |
50 |
69 |
|
70 def test_pickleable(self): |
|
71 b = Binary(b'toto') |
|
72 bb = pickle.loads(pickle.dumps(b)) |
|
73 self.assertEqual(b, bb) |
|
74 |
51 |
75 |
52 if __name__ == '__main__': |
76 if __name__ == '__main__': |
53 from unittest import main |
77 from unittest import main |
54 main() |
78 main() |