Python Behave tests not running on bitBucket CI

Viewed 449

We have a Simple Python Behave based test suite. It runs fine on local environment.

Command used to run test:

pip3 install -r requirements.txt    
behave -D URL=https://api.ourUrl.org/test/shopping

There's an optional npm based Allure report generation step, but that's not point of focus for the issue.

Error trace from Bitbucket run:

Then the shopping service will return HTTP 200 OK status # features/steps/shopping_api.py:34 Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/behave/model.py", line 1329, in run match.run(runner.context) File "/usr/local/lib/python3.7/site-packages/behave/matchers.py", line 98, in run self.func(context, *args, **kwargs) File "features/steps/shipping_api.py", line 78, in step_impl assert context.response.status_code == int(statusCode) AssertionError

Requirement.txt:

astroid==2.3.3
attrs==19.3.0
behave==1.2.6
certifi==2019.11.28
chardet==3.0.4
idna==2.8
isort==4.3.21
lazy-object-proxy==1.4.3
lxml==4.4.2
mccabe==0.6.1
parse==1.14.0
parse-type==0.5.2
Pillow==5.4.1
pylint==2.4.4
pypng==0.0.20
requests==2.22.0
six==1.14.0
tinycss2==0.6.1
transitions==0.6.9
typed-ast==1.4.0
ua-parser==0.8.0
urllib3==1.25.7
webencodings==0.5.1
wrapt==1.11.2
xmlrunner==1.7.7
regex==2020.5.7

I have tried switching from pip to pip3 on pipeline & also added regex==2020.5.7 but its not having any effect. Kindly advise how to fix this? Thanks a lot

Also note that we're using "re" matchers

enter image description here

1 Answers

It runs fine on local environment.

Expected 200 and getting status code -> 403

Yes. All tests are failing. But if I do curl from bitbucket yaml file, directly to endpoint then its returning Success

So, according to me:

  1. There couldn't be a logic error, as it worked on localhost
  2. There couldn't be a connection error, as it worked on curl from bitbucket yaml file just fine

The only possible answer to this if all you say and did is currect is that you may not have whitelisted the IP address of the Bitbucket to allow the end point

Or, if all or some things you said may be wrong, then you could have some kinda of logic error or some support error on the OS that Bitbucket CI works on(i.g. try doing to tests in a virtual machine).

Related