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 handling of None in allowed_domains #4410
Conversation
Nones in allowed_domains ought to be ignored and there are also tests for that scenario. This commit fixes the handling of None and also the accompanying tests which are now executed again.
Codecov Report
@@ Coverage Diff @@
## master #4410 +/- ##
==========================================
- Coverage 84.56% 84.56% -0.01%
==========================================
Files 166 166
Lines 9869 9872 +3
Branches 1467 1467
==========================================
+ Hits 8346 8348 +2
Misses 1268 1268
- Partials 255 256 +1
|
class TestOffsiteMiddleware3(TestOffsiteMiddleware2): | ||
|
||
def _get_spider(self): | ||
return Spider('foo') | ||
def _get_spiderargs(self): | ||
return dict(name='foo') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an aside. Does this class even do anything? Or could we clean this up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already the clean up! :)
The purpose of the class TestOffsiteMiddleware3
was to test that not setting the allowed_domains
attribute at all in a spider works. However, due to a refactoring, the test was effectively a no-op because _get_spider()
was never executed. My change should fix the test so it actually tests that use case again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, of course. I blanked out the subclassing of TestOffsiteMiddleware2
somehow. Looks good.
Could you add a testcase for the |
The test case for |
allowed_domains = [None]
leads to the following exception:However, Nones in allowed_domains ought to be ignored and there are also tests for that scenario. This commit fixes the handling of None and also the accompanying tests which are now executed again.