Closed marcel-goldschen-ohm closed 1 year ago
I've never used QAbstractItemModelTester
outside of pytest-qt, but at a glance, your code seems like it should work.
However, this isn't really all too related to pytest-qt so far. Did you try something like the example in the pytest-qt docs you linked to?
Thanks for the quick response @The-Compiler.
It seems my code above did work as I eventually got some error messages when doing something else (they are so cryptic as to not be very useful, but at least it's working). For whatever reason, no error messages are reported during the segfault behavior that I was originally looking at, so I had no way of knowing if the tester was working or not. Perhaps some initialization message would be helpful for sanity's sake.
Cheers
QAbstractItemModelTester
is coming from Qt. All pytest-qt does is integrating it into pytest.
I am starting to realize I have no idea how to use pytest. Do the docs have a complete example somewhere? All I see are tiny bits of code or floating functions that are not helping me understand how to set things up.
The function in the docs is a complete example (minus the imports) which you would run with pytest
. See the pytest docs as well.
Yes, well that's part of the rub for a newbie. Anyway, I'll clearly have to read up on pytest. Thanks again @The-Compiler.
Cheers,
I can see how this is confusing if you've never used pytest before - but I don't think it's the job of the pytest-qt documentation to explain how pytest works. I see that as a prerequisite, just like basic Qt or Python knowledge.
Out of curiosity, how did you find out about pytest-qt if it wasn't via pytest?
Fair enough.
QAbstractItemModelTester came up during searches for debugging a custom tree model derived from QAbstractItemModel, which led to pytest-qt.
I've read the docs at https://doc.qt.io/qt-6/qabstractitemmodeltester.html and https://pytest-qt.readthedocs.io/en/latest/modeltester.html, but I still fail to understand how to implement
QAbstractItemModelTester
to test a customQAbstractItemModel
.The following code/pseudocode (in my actual code I instantiate the model/view and add data properly) does not seem to do anything or else I am not properly configuring things to get the reports:
I'm hoping to get some debug info as to why the seg fault is occurring (yes, I've already tried commenting tons of things in my code, but I still haven't been able to track it down, so I'm hoping to use QAbstractItemModelTester). However, I don't see where QAbstractItemModelTester might be logging any such info if it is even working at all. Probably I'm not understanding how to implement it correctly, so any help would be awesome as I find the docs mentioned above uninformative. Note, I am using VSCode if that matters.
Cheers