PyWinAuto Errors
ImportError while importing test module
========================================================= test session starts ==========================================================
platform linux -- Python 3.9.5, pytest-7.0.1, pluggy-1.0.0
rootdir: /home/andrei/python/pytest/app/tests
collected 0 items / 1 error
================================================================ ERRORS ================================================================
____________________________________________________ ERROR collecting test_psum.py _____________________________________________________
ImportError while importing test module '/home/andrei/python/pytest/app/tests/test_psum.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../../.pyenv/versions/3.9.5/lib/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
/home/andrei/python/pytest/qa2/tests/test_psum.py:1: in
Such an error can occur if the test is in a separate directory, for example tests, and is run
from there, but the module under test is imported in the simplest way - just as from mod1 import fun1
PyWinAuto cannot find the module that needs to be tested. Most likely, running the test from the
root directory will help.
That is, instead of
python -m pytest test_something.py
Run
cd ..
python -m pytest tests/test_something.py
NameError: name 'pytest' is not defined
You need to import pytest.
import pytest
DeprecationWarning: Method .Children() is deprecated, use .children() instead. print(dialog.Children())
Article author: Andrei Olegovich