Merge pull request #5482 from alexpdev/parse_help_msg

Fix TypeError in parse command
This commit is contained in:
Andrey Rahmatullin 2022-04-29 11:10:15 +05:00 committed by GitHub
commit b9b9422bb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -51,7 +51,7 @@ class Command(BaseRunSpiderCommand):
parser.add_argument("--cbkwargs", dest="cbkwargs",
help="inject extra callback kwargs into the Request, it must be a valid raw json string")
parser.add_argument("-d", "--depth", dest="depth", type=int, default=1,
help="maximum depth for parsing requests [default: %default]")
help="maximum depth for parsing requests [default: %(default)s]")
parser.add_argument("-v", "--verbose", dest="verbose", action="store_true",
help="print each depth level one by one")

View File

@ -930,3 +930,17 @@ class MySpider(scrapy.Spider):
args = ['-o', 'example1.json', '-O', 'example2.json']
log = self.get_log(spider_code, args=args)
self.assertIn("error: Please use only one of -o/--output and -O/--overwrite-output", log)
class HelpMessageTest(CommandTest):
def setUp(self):
super().setUp()
self.commands = ["parse", "startproject", "view", "crawl", "edit",
"list", "fetch", "settings", "shell", "runspider",
"version", "genspider", "check", "bench"]
def test_help_messages(self):
for command in self.commands:
_, out, _ = self.proc(command, "-h")
self.assertIn("Usage", out)