File -> Settings -> Tools -> Python Integrated Tools -> Testing -> Default test runner -> select pytest from the dropdown -> OK
Tested with pycharm 2022.1
Ref: https://stackoverflow.com/questions/6397063/how-do-i-configure-pycharm-to-run-py-test-tests
On the unused import line press Alt+Enter → “Optimize imports” → Disable inspection
To revert back to the normal behaviour
Ctrl+Alt+s → Inspections → search for “unresolved references” → select the one in Python → check
released, version 2023-03-29, 2023.1 2023-03-09, 2022.3.3 2023-03-15, 2022.2.5 2022-08-16, 2022.2.1 2022-04-12, 2022.1 2021-07-27, 2021.2 2021-04-06, 2021.1 2020-12-01, 2020.3 2020-07-28, 2020.2 2020-04-07, 2020.1 2019-10-31, 2019.2.4 2019-09-25, 2019.2.3 2019-07-30, 2019.1.4 2019-05-29, 2019.1.3 2019-05-07, 2019.1.2 2019-02-26, 2018.3.5 2019-01-29, 2018.3.4 2018-09-19, 2018.2.4 2018-04-09, 2018.1.1 2017-09-05, 2017.2.3 2017-08-23, 2017.2.2 2017-07-11, 2017.1.5
Ref:-