22

I am trying to run a GUI test using pytest and pywinauto. When I run the code normally, it does not complain.

However, when I am doing it via pytest, it throws a bunch of errors:

Windows fatal exception: code 0x8001010d

Note that the code still executes without problems and the cases are marked as passed. It is just that the output is polluted with these weird Windows exceptions.

What is the reason for this. Should I be concerned?

def test_01():
    app = Application(backend='uia')
    app.start(PATH_TO_MY_APP)
    main = app.window(title_re="MY_APP")
    main.wait('visible', timeout=8) # error occurs here
    time.sleep(0.5)
    win_title = f"MY_APP - New Project"
    assert win_title.upper() == main.texts()[0].upper() # error occurs here
Martin Evans
  • 45,791
  • 17
  • 81
  • 97
Joe
  • 353
  • 2
  • 6

4 Answers4

21

This is an effect of a change introduced with pytest 5.0.0. From the release notes:

#5440: The faulthandler standard library module is now enabled by default to help users diagnose crashes in C modules.

This functionality was provided by integrating the external pytest-faulthandler plugin into the core, so users should remove that plugin from their requirements if used.

For more information see the docs: https://docs.pytest.org/en/stable/usage.html#fault-handler

You can mute these errors as follows:

pytest -p no:faulthandler
Felix Zumstein
  • 6,737
  • 1
  • 30
  • 62
  • 3
    To avoid disabling faulthandler for all our tests, I used "faulthandler.disable()" then "faulthandler.enable()" within the problematic tests. – Gaëtan de Menten Jun 28 '21 at 13:57
  • Makes me wonder, is there a benefit to disabling faulthandler on some test specifically, rather than globally? @GaëtandeMenten – Nuclear03020704 Aug 07 '22 at 14:05
  • I our case, yes. We just don't want to see those errors for tests we know always produce them, but we *do* want to know if there are other such errors appearing in new tests or existing tests when changing our library. – Gaëtan de Menten Aug 08 '22 at 09:46
  • But what is the reason that there is an exception in some C-module if the faulthandler is enabled? What happens to the exception if the faulthandler is disabled? – Stiefel Mar 02 '23 at 12:22
4

I had the same problem with Python 3.7.7 32-bit and pytest 5.x.x. It was solved by downgrading pytest to v.4.0.0:

python -m pip install pytest==4.0

Perhaps all Python versions are not compatible with the newest pytest version(s).

Niko Föhr
  • 28,336
  • 10
  • 93
  • 96
  • 1
    Thanks. Solved my issues as well. I had Python 3.6.3 w/ PyTest 5.4.3. I downgraded to PyTest 4.6.11 and issues went away – DankMasterDan Jun 17 '20 at 20:36
-1

My workaround for now is to install pytest==4.6.11 With 5.0.0 the problem occurs the first time.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
  • 1
    Please highlight the additional insight your post provides in comparision to the older and upvoted existing answer. (If the now deleted part with your question was the relevant difference, then please delete this post and create instead a question.) – Yunnosch Jul 06 '20 at 15:24
-1

W10 box.

Have this problem using pytest 6.2.5 and pytest-qt 4.0.2.

I tried np8's idea: still got a horrible crash (without message).

I tried Felix Zumstein's idea: still got a horrible crash (without message).

Per this thread it appears the issue (in 'Doze) is a crap DLL.

What's strange is that pytest-qt and the qtbot fixture seem to work very well... until I get to this one test. So I have concluded that I have done something too complicated in terms of mocking and patching for this crap 'Doze DLL to cope with.

For example, I mocked out two methods on a QMainWindow subclass which is created at the start of the test. But removing these mocks did not solve the problem. I have so far spent about 2 hours trying to understand what specific feature of this test is so problematic. I am in fact trying to verify the functioning of a method on my main window class which "manufactures" menu items (QWidgets.QAction) based on about 4 parameters.

At this stage I basically have no idea what this "problem feature" is, but it might be the business of inspecting and examining the returned QAction object.

mike rodent
  • 14,126
  • 11
  • 103
  • 157