File tree Expand file tree Collapse file tree 2 files changed +32
-29
lines changed Expand file tree Collapse file tree 2 files changed +32
-29
lines changed Original file line number Diff line number Diff line change 2
2
from __future__ import absolute_import , print_function , division
3
3
import json
4
4
import unittest
5
- import collections
6
5
7
6
8
7
from nose .tools import eq_ as eq , assert_raises
11
10
from zarr .attrs import Attributes
12
11
from zarr .compat import binary_type , text_type
13
12
from zarr .errors import PermissionError
14
-
15
-
16
- class CountingDict (collections .MutableMapping ):
17
-
18
- def __init__ (self ):
19
- self .wrapped = dict ()
20
- self .counter = collections .Counter ()
21
-
22
- def __len__ (self ):
23
- return len (self .wrapped )
24
-
25
- def __iter__ (self ):
26
- return iter (self .wrapped )
27
-
28
- def __contains__ (self , item ):
29
- return item in self .wrapped
30
-
31
- def __getitem__ (self , item ):
32
- self .counter ['__getitem__' , item ] += 1
33
- return self .wrapped [item ]
34
-
35
- def __setitem__ (self , key , value ):
36
- self .counter ['__setitem__' , key ] += 1
37
- self .wrapped [key ] = value
38
-
39
- def __delitem__ (self , key ):
40
- self .counter ['__delitem__' , key ] += 1
41
- del self .wrapped [key ]
13
+ from zarr .tests .util import CountingDict
42
14
43
15
44
16
class TestAttributes (unittest .TestCase ):
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+ from __future__ import absolute_import , print_function , division
3
+ import collections
4
+
5
+
6
+ class CountingDict (collections .MutableMapping ):
7
+
8
+ def __init__ (self ):
9
+ self .wrapped = dict ()
10
+ self .counter = collections .Counter ()
11
+
12
+ def __len__ (self ):
13
+ return len (self .wrapped )
14
+
15
+ def __iter__ (self ):
16
+ return iter (self .wrapped )
17
+
18
+ def __contains__ (self , item ):
19
+ return item in self .wrapped
20
+
21
+ def __getitem__ (self , item ):
22
+ self .counter ['__getitem__' , item ] += 1
23
+ return self .wrapped [item ]
24
+
25
+ def __setitem__ (self , key , value ):
26
+ self .counter ['__setitem__' , key ] += 1
27
+ self .wrapped [key ] = value
28
+
29
+ def __delitem__ (self , key ):
30
+ self .counter ['__delitem__' , key ] += 1
31
+ del self .wrapped [key ]
You can’t perform that action at this time.
0 commit comments