-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6799861
commit 68e1cc9
Showing
4 changed files
with
108 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .test_middleware import DelAttrAutounitMiddleware, DelObjectsAutounitMiddleware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from scrapy_autounit.middleware import AutounitMiddleware | ||
|
||
|
||
class DelAttrAutounitMiddleware(AutounitMiddleware, object): | ||
|
||
def process_spider_output(self, response, result, spider): | ||
if hasattr(spider, 'test_attr'): | ||
delattr(spider, 'test_attr') | ||
|
||
return super(self.__class__, self).process_spider_output(response, | ||
result, | ||
spider) | ||
|
||
|
||
class DelObjectsAutounitMiddleware(AutounitMiddleware, object): | ||
|
||
def process_spider_output(self, response, result, spider): | ||
result = [] | ||
return super(self.__class__, self).process_spider_output(response, | ||
result, | ||
spider) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters