File tree Expand file tree Collapse file tree 3 files changed +20
-10
lines changed
Expand file tree Collapse file tree 3 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,6 @@ def _tempfile(reader, suffix=''):
9393 try :
9494 os .write (fd , reader ())
9595 os .close (fd )
96- del reader
9796 yield Path (raw_path )
9897 finally :
9998 try :
@@ -109,11 +108,15 @@ def as_file(path):
109108 Given a Traversable object, return that object as a
110109 path on the local file system in a context manager.
111110 """
112- reader = path .read_bytes
113- with _tempfile (reader , suffix = path .name ) as local :
114- # release the handle to the path and reader
115- del reader
116- del path
111+ content = path .read_bytes ()
112+ name = path .name
113+
114+ def reader ():
115+ return content
116+
117+ del path .root
118+ del path
119+ with _tempfile (reader , suffix = name ) as local :
117120 yield local
118121
119122
Original file line number Diff line number Diff line change @@ -96,11 +96,18 @@ def path(
9696 return (
9797 _path_from_reader (reader , resource )
9898 if reader else
99- _common .as_file (
100- _common .files (package ).joinpath (_common .normalize_path (resource )))
99+ _fallback_path (package , resource )
101100 )
102101
103102
103+ @contextmanager
104+ def _fallback_path (package , resource ):
105+ files = _common .files (package ).joinpath (_common .normalize_path (resource ))
106+ with _common .as_file (files ) as res :
107+ del files
108+ yield res
109+
110+
104111@contextmanager
105112def _path_from_reader (reader , resource ):
106113 norm_resource = _common .normalize_path (resource )
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ skip_missing_interpreters = True
66
77[testenv]
88commands =
9- !cov,!diffcov: python -m unittest discover
10- cov,diffcov: python -m coverage run {[coverage]rc} -m unittest discover { posargs}
9+ !cov,!diffcov: python -m unittest {posargs: discover}
10+ cov,diffcov: python -m coverage run {[coverage]rc} -m unittest {posargs: posargs}
1111 cov,diffcov: python -m coverage combine {[coverage]rc}
1212 cov: python -m coverage html {[coverage]rc}
1313 cov: python -m coverage xml {[coverage]rc}
You can’t perform that action at this time.
0 commit comments