Fix ResourceWarnings in tests#1660
Conversation
1120982 to
e2ff841
Compare
|
|
||
|
|
||
| @contextmanager | ||
| def file_or_filename(input): |
There was a problem hiding this comment.
As I see in usage, this function used as contextmanager, why you remove this (@contextmanager + yield) ?
There was a problem hiding this comment.
Oh, it really doesn't work as was expected, nice catch!
There was a problem hiding this comment.
After meged comment:
Actually, it was already brokenl. Compare with code:
from contextlib import contextmanager
@contextmanager
def g():
print("g input")
yield
print("g exit")
@contextmanager
def f():
print("f input")
yield g()
print("f exit")
with f():
print("with block")
This code prints:
f input
with block
f exit
But expected something like:
f input
g input
with block
g exit
f exit
Back to the file_or_filename, methods __enter__ and __exit__ of smart_open(input) or input are not called at all. Oops.
| if docid != previd: | ||
| if previd >= 0: | ||
| return document | ||
| break |
There was a problem hiding this comment.
Can you add a test for this?
There was a problem hiding this comment.
Hmm, ok. But I don't understand what exactly should I check in it ?
There was a problem hiding this comment.
I read full method definition, now it's clear for me, thanks.
No description provided.