I am getting this error when I run login_tests.py
(venv) C:\Users\PRAGITI\PycharmProjects\lrtskodeit\tests>py.test Home/login_tests.py --browser chrome
ERROR: usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: --browser chrome
inifile: None
rootdir: C:\Users\PRAGITI\PycharmProjects\lrtskodeit\tests
(venv) C:\Users\PRAGITI\PycharmProjects\lrtskodeit\tests>
From the error, I could ascertain that you have not added the command line argument "browser" in your pytest.addoption().
However, IF the above solution is not useful, then it would be helpful if you provide your script content.
Related
I'm so far learning CircleCI builds and things and this is just a test/example to practice. I have a example test_page.py file with some Selenium (python) code. It uses chromedriver, and, what's important (I guess), this script has something like that:
s=Service('C:\Program Files\chromedriver.exe')
browser = webdriver.Chrome(service=s)
It looks like that, because without these lines my test code didn't execute. After some time I managed to put correct config.yml for this script, too. Now I know that (most likely) everything is okay - it upgrades pip, installs dependencies without errors etc. but now is problem with executing this test_page.py - because of these 2 lines above, I guess. Below is full error report from CircleCI:
And below is my config.yml file if it's needed. I was trying with circleci's orb for browsers from: https://circleci.com/developer/orbs/orb/circleci/browser-tools But I'd have no idea where could it install - so I could change this s=Service('C:\Program Files\chromedriver.exe') . Could it work with /usr/local/bin/chromedriver.exe?
version: 2.1
jobs:
build:
docker:
- image: circleci/python:3.8
- image: selenium/standalone-chrome:3.11.0
steps:
- checkout
- run:
name: Upgrade pip
command: |
pip install --upgrade pip
- run:
name: Install Dependencies
command: |
pip install -r requirements.txt
- run:
name: Run Selenium Tests
command: |
python -m pytest test_page.py
How should I change my config.yml OR test_page.py code to make it viable for circleci?
EDIT:
I added chromedriver-py to my requirements.txt file, so one error disappeared - I guess here's problem with something different:
raise KeyError(key) from None
E KeyError: 'DISPLAY'
So now it looks like this:
EDIT2: looks like it was pyautogui's fault, I removed it from my code, but now chromedriver's path is still wrong... I changed path, but error (look below) appears. WHERE should I put chromedriver's path? And can I make it work with pyautogui?
ERROR test_page.py - selenium.common.exceptions.WebDriverException: Message: Service /usr/local/bin/chromedriver.exe unexpectedly exited. Status code was: 127
And below errors in circleci - with pyautogui removed and s=Service set to: s=Service('/usr/local/bin/chromedriver.exe')
Without s=Service and with just browser = webdriver.Chrome()
============================= test session starts ==============================
platform linux -- Python 3.8.12, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/circleci/project
collecting ...
collecting 0 items / 1 error
collected 0 items / 1 error
==================================== ERRORS ====================================
________________________ ERROR collecting test_page.py _________________________
test_page.py:14: in <module>
browser = webdriver.Chrome()
../.local/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py:81: in __init__
super().__init__(
../.local/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py:103: in __init__
self.service.start()
../.local/lib/python3.8/site-packages/selenium/webdriver/common/service.py:106: in start
self.assert_process_still_running()
../.local/lib/python3.8/site-packages/selenium/webdriver/common/service.py:119: in assert_process_still_running
raise WebDriverException(f"Service {self.path} unexpectedly exited. Status code was: {return_code}")
E selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127
=========================== short test summary info ============================
ERROR test_page.py - selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.85s ===============================
Exited with code exit status 2
My overall aim is to run the Deep_Learning_keras which is a SpaCy example in Google Colab (ie in Jupyter Notebooks)
The GitHub link to the Deep_Learning_keras SpaCy example is:https://github.com/explosion/spaCy/blob/master/examples/deep_learning_keras.py
When I ran the example code directly in Google Colab I got the following error:
usage: ipykernel_launcher.py [-h] [-r] [-H 64] [-L 100] [-d 0.5] [-e 0.001]
[-i 5] [-b 256] [-n -1][model_dir] [train_dir] [dev_dir]
ipykernel_launcher.py: error: unrecognized arguments: -f
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
I understand that the example was originally written for python and that running the copy in a Jupyter Notebook environment is not entirely compatible. I'm not sure what code/statements I need to change in the example to make it compatible
I did a google search for the SystemExit: 2 error and the closest example I found was (however the problem within the SystemExit: 2 is different to my problem):
SystemExit: 2 error when calling parse_args() in iPython Notebook
Thanks
I am playing a little bit with snapcraft and everything worked fine but now I get following error - I have no clue what causes the error:
Successfully installed appdirs packaging pip-8.1.2 pyparsing-2.1.8 setuptools-26.1.1 six-1.10.0 wheel-0.29.0
/home/bla/bla/parts/myapp/install/usr/bin/python2 -m pip download --disable-pip-version-check --dest /home/bla/bla/parts/myapp/packages . setuptools
/tmp/tmps75wvcfe: 10: export: distribution/linux/Snapping/myapp/stage/usr/share/perl5/: bad variable name
Command '['/bin/sh', '/tmp/tmpseb6idqm', '/home/bla/bla/parts/myapp/install/usr/bin/python2', '-m', 'pip', 'download', '--disable-pip-version-check', '--dest', '/home/bla/bla/parts/myapp/packages', '.', 'sqlalchemy']' returned non-zero exit status 2
My snapcraft.yaml file:
name: myapp
version: "1.0"
summary: myapp snap test
confinement: devmode
grade: devel
apps:
myapp:
command: myapp
parts:
myapp:
plugin: python
python-version: python2
python-packages:
- setuptools
source: ./src/foo
source-type: git
stage-packages:
- python-pyqt5
- python-sqlalchemy
- python-setuptools
Do you have any ideas what could cause the error?
I had the same problem which seemed to be caused by space characters in the path to where I was building the snap.
My original path was:
~/Documents/Programming Projects/Python Projects/TemperaturePi
and snapcraft gave the same error.
I moved the directory to:
~/Documents/TemperaturePi
and the snap built without the above error.
Looking at the py.test documentation it would seem that passing -n NUM would specify the number of cores to be used.
My experience is the following:
usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: -n
If I try to specify it in pytest.ini (which is my preference) I get the same result.
I'm adding addopts = -n4 to the ini file, which seems to be what the docs require.
I'm using py.test 2.8, and I've tried both python 2 and python 3.
You need to install xdist
pip install pytest-xdist
I am trying to use the memory_profiler module to profile the memory usage of a large Python program. There seems to be a memory leak somewhere in my program, so I'm hoping this module will help me find the leak.
I installed memory_profiler using pip and tested it with the sample code provided here. This works perfectly.
When I try to use it with my program, I add the #profile decorator to my main() function and run the profiler from the command line the same way:
$ python -m memory_profiler engine.py
I get the following error, and my program fails to run (everything hangs):
usage: memory_profiler.py [-h] [-c CHARSET] [-i] [-o] [-l LOG_LEVEL] [-g] [-k]
[-w] [-s STOP] [-x TEXTS] [-z SIZE] [-t TIMEOUT]
[-p] [-d DEVICE]
memory_profiler.py: error: unrecognized arguments: engine.py
Any ideas what I might be doing wrong?