| 60 | assert "[myspider] DEBUG: FEEDS: {'example.json': {'format': 'json'}}" in log |
| 61 | |
| 62 | def test_overwrite_output(self, proj_path: Path) -> None: |
| 63 | spider_code = """ |
| 64 | import json |
| 65 | import scrapy |
| 66 | |
| 67 | class MySpider(scrapy.Spider): |
| 68 | name = 'myspider' |
| 69 | |
| 70 | async def start(self): |
| 71 | self.logger.debug( |
| 72 | 'FEEDS: {}'.format( |
| 73 | json.dumps(self.settings.getdict('FEEDS'), sort_keys=True) |
| 74 | ) |
| 75 | ) |
| 76 | return |
| 77 | yield |
| 78 | """ |
| 79 | j = proj_path / "example.json" |
| 80 | j.write_text("not empty", encoding="utf-8") |
| 81 | args = ["-O", "example.json"] |
| 82 | log = self.get_log(spider_code, proj_path, args=args) |
| 83 | assert ( |
| 84 | '[myspider] DEBUG: FEEDS: {"example.json": {"format": "json", "overwrite": true}}' |
| 85 | in log |
| 86 | ) |
| 87 | with j.open(encoding="utf-8") as f2: |
| 88 | first_line = f2.readline() |
| 89 | assert first_line != "not empty" |
| 90 | |
| 91 | def test_output_and_overwrite_output(self, proj_path: Path) -> None: |
| 92 | spider_code = """ |