Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSCRAPY_CHECK is not set while running contract #4222
Comments
|
The variable is only defined at initialization, not at run time. If you have a look at the code example from the documentation, you’ll notice that it is used in I’m turning this ticket into a documentation enhancement request. If you would rather it be a request to have the environment variable also available at run time, from callback, please let me know. |
|
Thanks for the quick answer. I think it could be nice to have it available for the callback running in check mode. But from there I can definitely build the check awareness feature that I want from EDIT: After giving a little bit more thought I think I will stay with doc enhancement as in my case it's more a trick in my spider that is forcing another trick! |
|
While I agree that the current behaviour does match the docs, I wonder if this isn't a reasonable use case. From a very quick look, it seems like it could be solved by just including the next code block in the diff --git scrapy/commands/check.py scrapy/commands/check.py
index 9d4437a4..09a76ca7 100644
--- scrapy/commands/check.py
+++ scrapy/commands/check.py
@@ -78,19 +78,19 @@ class Command(ScrapyCommand):
elif tested_methods:
self.crawler_process.crawl(spidercls)
- # start checks
- if opts.list:
- for spider, methods in sorted(contract_reqs.items()):
- if not methods and not opts.verbose:
- continue
- print(spider)
- for method in sorted(methods):
- print(' * %s' % method)
- else:
- start = time.time()
- self.crawler_process.start()
- stop = time.time()
-
- result.printErrors()
- result.printSummary(start, stop)
- self.exitcode = int(not result.wasSuccessful())
+ # start checks
+ if opts.list:
+ for spider, methods in sorted(contract_reqs.items()):
+ if not methods and not opts.verbose:
+ continue
+ print(spider)
+ for method in sorted(methods):
+ print(' * %s' % method)
+ else:
+ start = time.time()
+ self.crawler_process.start()
+ stop = time.time()
+
+ result.printErrors()
+ result.printSummary(start, stop)
+ self.exitcode = int(not result.wasSuccessful())Any thoughts? |
|
I have no strong opinion either way. @Matthijsy Do you remember if you had a reason not to apply the environment variable at run time? |
|
I am not sure why I did it that way. I think it would be fine to include the check run itself in the environment variable block as well. |
|
Is someone working on this? If not I'd like to work on this. |
|
@Gallaecio @Matthijsy |
|
The code has an added tab to include it within the context of |
|
Got it. My bad. |
|
#4298, from @faizan2700, is only missing tests. If @faizan2700 is busy, maybe someone else can work on tests, and send a pull request to the corresponding branch in his fork, or create a new pull request built on top of his changes. |
|
when i run tests using tox command in scrapy directory instead of running tests I am getting exception (ValueError : No closing quotation). I tried to check this online but couldn't solve the problem. Can someone please help me on this (@Gallaecio ) . Thank You |
Description
Hi, it seems that #3739 is not doing what the documentation describe:
os.environ.get('SCRAPY_CHECK')is returningNonein my contract check.Steps to Reproduce
Expected behavior: Request should be yielded as per the documentation
Actual behavior: Nothing happen
Reproduces how often: In my local project and with fresh project
Versions
Windows
Linux