@@ -88,42 +88,42 @@ def _assert_pack_file(self, pack, version, size):
88
88
89
89
num_obj = 0
90
90
for obj in pack .stream_iter ():
91
- num_obj += 1
92
- info = pack . info ( obj . pack_offset )
93
- stream = pack .stream (obj .pack_offset )
94
-
95
- assert info .pack_offset == stream .pack_offset
96
- assert info .type_id == stream .type_id
97
- assert hasattr (stream , 'read' )
98
-
99
- # it should be possible to read from both streams
100
- assert obj .read () == stream .read ()
101
-
102
- streams = pack .collect_streams (obj .pack_offset )
103
- assert streams
104
-
105
- # read the stream
106
- try :
107
- dstream = DeltaApplyReader .new (streams )
108
- except ValueError :
109
- # ignore these, old git versions use only ref deltas,
110
- # which we havent resolved ( as we are without an index )
111
- # Also ignore non-delta streams
112
- continue
113
- # END get deltastream
114
-
115
- with dstream :
116
- # read all
117
- data = dstream .read ()
118
- assert len (data ) == dstream .size
119
-
120
- # test seek
121
- dstream .seek (0 )
122
- assert dstream .read () == data
123
-
124
- # read chunks
125
- # NOTE: the current implementation is safe, it basically transfers
126
- # all calls to the underlying memory map
91
+ with obj :
92
+ num_obj += 1
93
+ info = pack .info (obj .pack_offset )
94
+ with pack . stream ( obj . pack_offset ) as stream :
95
+ assert info .pack_offset == stream .pack_offset
96
+ assert info .type_id == stream .type_id
97
+ assert hasattr (stream , 'read' )
98
+
99
+ # it should be possible to read from both streams
100
+ assert obj .read () == stream .read ()
101
+
102
+ streams = pack .collect_streams (obj .pack_offset )
103
+ assert streams
104
+
105
+ # read the stream
106
+ try :
107
+ dstream = DeltaApplyReader .new (streams )
108
+ except ValueError :
109
+ # ignore these, old git versions use only ref deltas,
110
+ # which we havent resolved ( as we are without an index )
111
+ # Also ignore non-delta streams
112
+ continue
113
+ # END get deltastream
114
+
115
+ with dstream :
116
+ # read all
117
+ data = dstream .read ()
118
+ assert len (data ) == dstream .size
119
+
120
+ # test seek
121
+ dstream .seek (0 )
122
+ assert dstream .read () == data
123
+
124
+ # read chunks
125
+ # NOTE: the current implementation is safe, it basically transfers
126
+ # all calls to the underlying memory map
127
127
128
128
# END for each object
129
129
assert num_obj == size
@@ -142,6 +142,11 @@ def test_pack(self):
142
142
self ._assert_pack_file (pack , version , size )
143
143
# END for each pack to test
144
144
145
+ ## Unless HIDE_WINDOWS_KNOWN_ERRORS, on Windows fails with:
146
+ # File "D:\Work\gitdb.git\gitdb\util.py", line 141, in onerror
147
+ # func(path) # Will scream if still not possible to delete.
148
+ # PermissionError: [WinError 32] The process cannot access the file
149
+ # because it is being used by another process: 'sss\\index_cc_wll5'
145
150
@with_rw_directory
146
151
def test_pack_entity (self , rw_dir ):
147
152
pack_objs = list ()
0 commit comments