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

test_pipeline_images.py fails with "TypeError: Skipped expected string as 'msg' parameter, got 'bool' instead." #5020

Closed
wRAR opened this issue Mar 2, 2021 · 10 comments · Fixed by #5022 or #5027
Assignees
Labels

Comments

@wRAR
Copy link
Member

wRAR commented Mar 2, 2021

See e.g. https://github.com/scrapy/scrapy/pull/5019/checks?check_run_id=2012658916

This should be related to the skip attribute, though I'm not sure why did it start happening now.

@wRAR
Copy link
Member Author

wRAR commented Mar 2, 2021

OK, looks like it's because of the Twisted upgrade, because of twisted/twisted@beafcd6

Note that the docs have already said "None or a string".

@wRAR
Copy link
Member Author

wRAR commented Mar 2, 2021

Looks like changing False to None helps, but on the other hand the skipping code doesn't really work, as PIL is imported in scrapy.pipelines.images and so the test fails with an ImportError anyway.

@Gallaecio
Copy link
Member

My bad for getting this closed. Let’s keep it open until we figure out the right way forward.

@wRAR
Copy link
Member Author

wRAR commented Mar 3, 2021

So the easy way is just replacing False with None. A better one is either fixing the no-PIL code path and adding tests for it (I don't see a reason for this additional complexity TBH) or dropping it and saying "we require PIL for tests".

@Gallaecio
Copy link
Member

I still don’t see what’s wrong with our code. skipIf(bool, reason) should work, and instead is causing this issue about the reason being a boolean, as if somewhere in the middle the first parameter of skipIf got interpreted as the reason.

@wRAR
Copy link
Member Author

wRAR commented Mar 3, 2021

The class skip attribute previously was checked with if, now it is checked with is None: twisted/twisted@beafcd6 (respectively the old line 1076 and the new line 1040).

@Gallaecio
Copy link
Member

But is that a bug in Twisted that we should report, or does the fix need to happen in our code or code we use (e.g. pytest-twisted)?

@wRAR
Copy link
Member Author

wRAR commented Mar 3, 2021

It's a bug in our code as we set skip to False when the docs say L{None} or a string explaining why this test is to be skipped. If defined, the test will not be run.

@Gallaecio
Copy link
Member

I see. When I was looking at the code to check for this issue, I became convinced that our use of skipIf in https://github.com/scrapy/scrapy/blob/master/tests/test_pipeline_images.py#L187 was one of the cases where the issue was triggered. But it’s not, it’s the use of skip in other parts of the file as a string what’s triggering it.

OK, so it should be relatively easy to fix.

@Boris-code

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants