The CI tests for our open sourced framework suddenly started failing with:
argparse.ArgumentError: argument -V/--ver: conflicting option string: -V. Pytest was clearly telling us that the -V option was being used elsewhere. But it was not clear about where the ‘used elsewhere’ was located. Further, while we knew what the error meant but could not understand why the error would suddenly surface given that we had not recently changed our options at all. This post outlines the easiest way for you to debug similar issues when running pytest. It also outlines our fix for the same.
Note: This debug method is specific to pytest and not a general one pertaining to argparse!
To debug the problem, we had to first comment out the ‘-V’ option we had declared in conftest.py. After that, we ran
pytest --help and see the list of all options (standard, custom, plugin, etc.) in pytest.
Scrolling through that list we spotted that the test session and debugging configuration section had a -V option. The CI tests on our framework optimistically use the latest version of pytest with every run. So we guess that the change in pytest’s ‘test session debugging and configuration’ section must have happened recently.
Now that we could locate the issue, we had a choice to make. We could either override the ‘-V’ used by pytest or remove the ‘-V’ option from our framework. Doing the latter felt more responsible. We should probably go away from single character custom option statements anyway. So we went ahead and removed the ‘-V’ option but still kept the long form or ‘–ver’ option in our framework.
If you are one of the dozens of companies already using our open-sourced automation framework and you recently upgraded your pytest version, please follow the fix here.
Removing the ‘-V’ change requires the following files/places to be updated:
a) conftest.py in:
pytest_generate_tests() where we create the browser list
b) If you use our framework, please replace ‘-V’ with
--ver wherever you were previously sending browser version through the -V command line option. For example, in your CI configuration files.
Hope this helps!
I want to find out what conditions produce remarkable software. A few years ago, I chose to work as the first professional tester at a startup. I successfully won credibility for testers and established a world-class team. I have lead the testing for early versions of multiple products. Today, I run Qxf2 Services. Qxf2 provides software testing services for startups. If you are interested in what Qxf2 offers or simply want to talk about testing, you can contact me at: [email protected]. I like testing, math, chess and dogs.