Python behave Gherkin Step parameter getting compile time Number expected exception - python-behave

Feature: Step Parameter Test
Scenario: look up a book
Given I search for a valid book
Then the result page will include "success"
Scenario: look up an invalid book
Given I search for a invalid book
Then the result page will include "failure"
Step Definition: getting exception Number expected between {}, Not considering status as parameter
#then('the result page will include {status}')
def step_impl(context,status):
"""
:type context: behave.runner.Context
"""
pass
Exception Screenshot:
I have tried even regular expression in that case getting steps undefined exception. didn't find any way to pass the string/number/double as parameter from feature file
Please do suggest if there is way to solve this.

It seems that, for whatever reason, your behave parser is 're'. when typically it's 'parse'.
In your test file add the following:
from behave import use_step_matcher
use_step_matcher('parse')
#the rest of your test here
##given...
behave documentation on use_step_matcher here.

Related

Error on one page that does not appear anywhere else

Hi so my wordpress site has just started acting up, I am not sure if its an update that has caused this but only on this one page I am getting this error regarding
Notice: Array to string conversion in /customers/c/1/7/veganantics.co.uk/httpd.www/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/Schemas/ImageAttachmentSchema.php on line 95
I can't seem to find the issue, I have tried replacing the file with a new core file and the error is still there, would really appreciate some help
This is the page: https://veganantics.co.uk/vegan-gifts/
Thank you
Ash
The theme, a plugin or some custom code is probably using the wp_calculate_image_sizes filter and returning an array instead of a string.
Do a text search on your install and look for wp_calculate_image_sizes. The function that you need to find will look similar to
add_filter('wp_calculate_image_sizes', 'something');
Explanation:
ImageAttachmentSchema.php on line 95 is calling wp_get_attachment_image_sizes which must be a string.
wp_get_attachment_image_sizes is returning wp_calculate_image_sizes( $size_array, $image_src, $image_meta, $attachment_id ) which again must be a string.
wp_calculate_image_sizes returns a filtered value, and that's the only place where such an error (array instead of a string) can happen. So, if the filter incorrectly returns an array, it bubbles up to the function that you see in the error log.

Can I do this extract code query in cakephp 3.5?

My code in ServiceDetailController
$users = $this->ServiceDetail->Users->find()->extract('first_name')->where(['position' => 2]);
I get an error:
Call to undefined method Cake\ORM\ResultSet::where()
Debugging basics: Check if the method exists in the called object. If not ask yourself why. Then check what extract() returns and you'll get your answer. You basic problem, as a metaphor is that you try to drink from a bottle before opening it. You can't extract without having a result first.
Extract does not return a query object. First build your query, then execute it, all() for example, and then call extract on the result object because it implements a collection that allows you to call extract() on it.

I started to using mothur version - v.1.36.1-, but I got some error messages (shown below). How I can overcome this?

I start the Mothur Tutorial (https://www.mothur.org/wiki/MiSeq_SOP). But from the beginning, I got some error messages when I create " make.file "in mothur*(Error commands are shown below). I changed parameters but the result was negative. How can I solve this problem?
****mothur > make.file(inputdir=MiSeq_SOP, type=fastq, prefix=stability)
Setting input directory to: MiSeq_SOP/
prefix is not a valid parameter.
The valid parameters are: type, seed, inputdir, and outputdir.
[ERROR]: did not complete make.file.****
Actually, the prefix parameter is a valid parameter in mothur. Personally, I have never encountered a problem with using a prefix for the make.file command, but your command should be valid.
You could test if your inputdir is specified correctly (the mothur error and warning messages are not necessarily the most clear ones). If this works as well, I suggest that you well document this behaviour and send it to the mothur team (in my experience, they are quite responsive and ready to help).

How to assert an actual value with two different expected values

I'm writing a protractor test which asserts a URL against two different browser URLs.
I tried using toMatch with a regular expression but I get an error.
Is it possible to assert an actual string value against 2 or more expected string values and see if it is equal to any of them?
expect(url1).toMatch(/this.url|www.google.com/);
Sounds like you want to use toContain() which works for finding an item in an array. So switch your assertion around because you want to pass it an array of URLs [this.url, 'www.google.com'] and assert that it will contain url1.
expect([this.url, 'www.google.com']).toContain(url1);
Note: While this should work, personally I don't like to have my values on the receiving end of the assertion i.e. toContain(url1), I would rather that be passed first expect(url1).... However, in the end it's still asserting actual vs expected values so not a huge deal in my opinion.
https://jasmine.github.io/2.0/introduction.html

error in declaring higher-order functions in XPath 3.0: must declare return type?

Following #DimitreNovatchev's article Programming in XPath 3.0, and using BaseX GUI as the test environment, I tried some of the examples that define functions that accept functions as parameters. E.g. with
let $compose :=
function($f as function(), $g as function())
(The rest of the code isn't relevant to this error, but you can see it as the third example under Function Composition.)
I get this error from BaseX:
Error:
Stopped at 43-compose.xpath, 2/39:
[XPST0003] Expecting 'as', found ','.
The point where the error was detected was on the second line, just before the comma. Apparently, the processor expects the $f parameter declaration to say not just that $f should be a function, but also the return value of the function.
I don't know whether it's right for BaseX to expect that or not. Presumably, Dimitre's examples tested successfully before he made that presentation at Balisage. Maybe something changed in the XPath 3.0 spec between that article and when BaseX was released?
OK, found the answer. I got an evaluation key for Saxon EE, so I was able to try another processor. For future reference, this was the command line:
C:\Program Files\Saxon>java -cp saxon9ee.jar net.sf.saxon.Query -s:"input.xml" -
q:"ex5.xpath" -qversion:3.0
Note that -qversion:3.0 is currently required in order to get any 3.0 functionality.
Saxon throws an error at the same point, but gives a helpful suggestion on how to fix it:
Error on line 2 column 39 of ex5.xpath:
XPST0003 XQuery syntax error near #... function($f as function(), $#:
function() is no longer allowed for a general function type: must be function(*)
I changed function() to function(*) wherever a general function type was wanted, and the errors went away, both in BaseX and in Saxon.
So apparently BaseX was correct (but Saxon's error message was more helpful, as is often the case!). Sounds like something did change in the spec recently. I haven't been able to figure out what the relevant change was, from the change log. But regardless of what changed, the spec currently says that a FunctionTest must have either a * within the parentheses, or an as after them. (This applies to declarations of parameters that are functions, but does not apply to inline functions themselves.)

Resources