Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ResourceWarnings in tests #1660

Merged
merged 1 commit into from
Oct 31, 2017

Conversation

horpto
Copy link
Contributor

@horpto horpto commented Oct 28, 2017

No description provided.

@@ -135,7 +134,6 @@ def __exit__(self, type, value, traceback):
nocm = NoCM()


@contextmanager
def file_or_filename(input):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I see in usage, this function used as contextmanager, why you remove this (@contextmanager + yield) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it really doesn't work as was expected, nice catch!

Copy link
Contributor Author

@horpto horpto Oct 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@@ -895,8 +895,11 @@ def docbyoffset(self, offset):
assert previd <= docid, "matrix columns must come in ascending order"
if docid != previd:
if previd >= 0:
return document
break
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, ok. But I don't understand what exactly should I check in it ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read full method definition, now it's clear for me, thanks.

@menshikh-iv menshikh-iv merged commit d7190f3 into piskvorky:develop Oct 31, 2017
@horpto horpto deleted the bugfix-ResourceWarning branch November 7, 2017 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants