Change syntax of -k option in pytest 7.1.0 is not working with pytest_addoption(parser) - pytest

Below is my code which was working perfectly fine till I upgraded pytest to version 7.1.0
pytest.main(self.pytest_args + ["-k", tc_cfg.name, "--aq-cfg", tc_cfg.aq_cfg])
and in conftest, I have below code:
def pytest_addoption(parser):
parser.addoption("--aq-cfg", required=False)
This was working fine for earlier pytest versions. With latest one(pytest 7.1.0) its failing with below error:
ERROR: usage: aqueduct [options] [file_or_dir] [file_or_dir] [...]
aqueduct: error: unrecognized arguments: --aq-cfg all_envs
inifile: /home/aquser/dev/aqueduct/src/cb/test/tools/aqueduct/pytest.ini
rootdir: /home/aquser/dev/aqueduct/src/cb/test/tools/aqueduct
This is occurring because latest change added for -k syntax: https://docs.pytest.org/en/stable/changelog.html#pytest-7-1-0-2022-03-13
But if I try to remove --aq-cfg, its failing at pytest_adoption(parsar) and not able to locate file without "--".
Any help on this would be appreciated!

Related

error Command failed with exit code 1. in compile protobufjs

I update protobufjs from 6.11.2 to 7.1.2 then when I run my compiler to compile my protobufs I got this error
Usage: pbjs [options] <schema_path>
Options:
-V, --version output the version number
--es5 <js_path> Generate ES5 JavaScript code
--es6 <js_path> Generate ES6 JavaScript code
--ts <ts_path> Generate TypeScript code
--decode <msg_type> Decode standard input to JSON
--encode <msg_type> Encode standard input to JSON
-h, --help output usage information
error Command failed with exit code 1.
What shall I do ?
I resolved this by adding protobufjs-cli.
yarn add protobufjs-cli

How to fix "pytest: error: unrecognized arguments: -n"

Hi I am trying to run my tests parallely(pytest-xdist) on the azure pipelines.
Till now the tests were running perfectly fine.
Suddenly the pytest is throwing a weird error saying "unrecognized argument".
The file name : integration_test.py
Command used : pytest -n 5 --tb=short integration_test.py -v -s --> to run 5 tests parallely
Total number of tests : 57
Versions :
pytest==6.2.5
pytest-xdist==2.3.0
Even tried with the latest versions of these 2 modules.
Error :
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: -n integration_test.py
How can I overcome this error?
This error is what you encountered:
As hoefling mentioned, the solution is to install the pytest-xdist:
pip install pytest-xdist
On MacOS just running pytest might be ran by a different Python's version than you thought.
$ pytest
============================================================================== test session starts ===============================================================================
platform darwin -- Python 3.9.12, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
rootdir: [REDACTED]
plugins: anyio-3.5.0, cov-3.0.0
While
$ python3 -m pytest
============================================================================== test session starts ===============================================================================
platform darwin -- Python 3.10.6, pytest-7.1.2, pluggy-1.0.0
rootdir: [REDACTED]
plugins: xdist-2.5.0, forked-1.4.0, pylama-8.4.1
Be careful, and launch it as a module :)

VS Code and pytest: Where is the default junit-xml output path defined and why is there one?

I am trying to run a debug the tests of my Python project inside the VS Code interface.
I followed the instruction from VS Code's website using pytest but when trying to run a test the output fails:
============================= test session starts =============================
platform win32 -- Python 3.8.10, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: c:\Users\myUserName\Projects\myProjectName
plugins: localserver-0.5.0
collected 1 item
myProjectName\tests\test_static_analysis.py . [100%]
- generated xml file: C:\Users\MYUSERNAME\AppData\Local\Temp\tmp-26696NTXW7ChqfMEN.xml
-
============================== 1 passed in 0.18s ==============================
Error: Error: cannot open file:///c%3A/Users/myUserName/Projects/myProjectName/C. Detail:
Unable to read file 'c:\Users\myUserName\Projects\myProjectName\C' (Error: Unable to resolve
non-existing file 'c:\Users\myUserName\Projects\myProjectName\C')
Error: Error: cannot open file:///c%3A/Users/myUserName/Projects/myProjectName/C. Detail:
Unable to read file 'c:\Users\myUserName\Projects\myProjectName\C' (Error: Unable to resolve
non-existing file 'c:\Users\myUserName\Projects\myProjectName\C')
Maybe VS Code doesn't have the authorization to write in AppData.
What concerns me is why is VS Code launching pytest with a junit-xml output option?
The command actually executed by VS Code is:
c:; cd 'c:\Users\myUserName\Projects\myProjectName'; & 'C:\ProgramData\Anaconda3\envs\venv-myProjectName\python.exe' 'c:\Users\myUserName\.vscode\extensions\ms-python.python-2021.8.1105858891\pythonFiles\lib\python\debugpy\launcher' '53774' '--' 'c:\Users\myUserName\.vscode\extensions\ms-python.python-2021.8.1105858891\pythonFiles\testlauncher.py' 'c:\Users\myUserName\Projects\myProjectName' 'pytest' '--override-ini' 'junit_family=xunit1' '--rootdir' 'c:\Users\myUserName\Projects\myProjectName' '--junit-xml=C:\Users\MYUSERNAME\AppData\Local\Temp\tmp-26696pYh1w3pF2cXx.xml' './myProjectName/tests/test_static_analysis.py::TestStaticAnalysisVesselForceOnLateralCenter::test_pos_surge_on_vessel'
When going in Settings > python.testing.pytestArgs it is empty.
Where is this output path defined?
How can I change it to be in the local working directory?
Do I need to have a junit-xml output? Is it mandatory for VS Code UI to work?

Issue with building a haskell-stack postgresql project

I'm trying to use stack to set up the yesod-postgres template project on my Windows machine. Unfortunately, when I run stack build I get the following result:
pg-project-0.0.0: build
Preprocessing library pg-project-0.0.0...
In-place registering pg-project-0.0.0...
Preprocessing executable 'pg-project' for pg-project-0.0.0...
Linking .stack-work\dist\95439361\build\pg-project\pg-project.exe ...
C:/Users/Rik/AppData/Local/Programs/stack/i386-windows/ghc-7.10.3/mingw/bin/ld.exe: cannot find -lpq
collect2.exe: error: ld returned 1 exit status
-- While building package pg-project-0.0.0 using:
C:\stack_root\setup-exe-cache\i386-windows\setup-Simple-Cabal-1.22.5.0-ghc-7.10.3.exe --builddir=.stack-work\dist\95439361 build lib:pg-project exe:pg-project --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
I've added C:\PostgreSQL\bin to my PATH, and I'm using the 32-bit version of PostgreSQL 9.5.
Any help is appreciated.

gcc is not Creating an Output File

The following command (via PowerShell in Windows 7)
PS C:\Users\gvkv\projects\stats> C:\mingw\bin\gcc.exe .\lex.yy.c -o gmstats.exe -v output
gives the following output
gcc.exe: error: output: No such file or directory
Using built-in specs.
COLLECT_GCC=C:\mingw\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.8.1/configure --prefix=/mingw --host=mingw32 --build=mingw32 --without-pic --enable-shared --enable-static --with-gnu-ld --enable-lto --enable-libssp --disable-multilib --enable-languages=c,c++,fortran,objc,obj-c++,ada --disable-sjlj-exceptions --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --with-gmp=/usr/src/pkg/gmp-5.1.2-1-mingw32-src/bld --with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld --with-mpfr= --with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable-libgomp --enable-threads --with-libiconv-prefix=/mingw32 --with-libintl-prefix=/mingw --disable-bootstrap LDFLAGS=-s CFLAGS=-D_USE_32BIT_TIME_T
Thread model: win32
gcc version 4.8.1 (GCC)
and I have no idea why. In particular, I don't understand the error at the top of the output. If I invoke gcc without the -v option:
PS C:\Users\gvkv\projects\stats> C:\mingw\bin\gcc.exe .\lex.yy.c -o gmstats.exe
I get:
PS C:\Users\gvkv\projects\stats>
Nominal success! This would be great if I also had gmstats.exe in my directory. Just for fun I've also tried running PowerShell as an administrator and I've also invoked gcc with an absolute path:
PS ...>C:\MinGW\bin\gcc.exe
just to make sure. I last used gcc to compile something (via make) and it worked fine.
I also considered that there was a linker (ld.exe) problem but there's no file to link and the search directories are fine.