[00:00] thomi, veebers: I have a customproxyobject that has a slow_drag method in it. I want to test the number of times that drag method was called. [00:02] I can't use mock to count the number of time drag was called, because that would do nothing instead of dragging. [00:02] and I can't make a test class that inherits from my customproxyobject class and counts the number of times drag was called, because I won't be able to use it on select_single [00:04] I'm out of ideas, but I might be missing some simple and straight-forward way to do it. [00:04] thomi, veebers: how would you do it? [00:05] elopio: hmm, I'm just checking a couple of ideas out. My first suggestion was super gross so I didn't even type it out :-) [00:05] elopio: a decorator? [00:05] I'm sure you acn do it thought, just pondering it [00:05] elopio: make a decorator that counts calls [00:05] thomi: aye, that's what I was thinking, wrap the call and have it count [00:06] thomi, veebers: but then it will count always. Not just for my test. [00:06] elopio: hmmm [00:07] could you have something like: with MethodCaller(object) as smoething:\n\n print something['method_'name'] => 12 [00:08] veebers: but that only works if he controls the call site [00:08] elopio: make your custom proxy class count the calls only when it's been enabled with a context manager [00:08] so you'd do: [00:08] I didn't get that. [00:08] with my_custom_proxy_class_instance.count_calls(): [00:08] # test code [00:08] assert my_custom_proxy_class_instance.call_count == 12 [00:08] I mean, the methodcaller solution. [00:10] thomi: ok, I don't like that, but I guess I'll go with it. [00:10] elopio: it's quite an unusual requirement [00:11] my ideal solution was something like mock.patch(CustomProxyObj, 'slow_drag'), so I didn't have to touch the original class [00:12] but instead of patching it with a mock, it keeps the same slow_drag implementation but records the call_count. [00:12] elopio: why do you want this? There's probably a better way [00:12] counting the number of calls seems like you're testing the wrong thing TBH [00:12] I'll propose it to mfoord, charge a cent for everybody who uses it, and then I will earn one cent. [00:13] thomi: on the qquicklistviews we have to drag the list many times in order to find items, right? [00:13] I'm now working with circular lists [00:13] if we drag too fast, we skip some items [00:14] but as it's circular, we might end up spinning many times until by mere chance we make visible the item we were looking for. [00:14] heh [00:14] I want a test that verifies that we are spinning only the expected number of times. [00:15] thomi: but you might be right. It could be that I'm too involved in the current solution that I can't think of an alternate test for this. [00:15] let me know if you have one in mind. [00:15] I think I'd do it based on the visible contents perhaps? [00:16] ok, that could work. [00:16] check what's the current selected index. [00:16] drag once. [00:16] check that the selected index is now the old one + 1 [00:18] it's a little harder when the drag is for more than one item at a time, because the toolkit doesn't tell you properly the numer of visible items. But that's a problem for later. [00:26] thomi, veebers: thanks! looks better now. [00:26] * elopio goes to the gym to become big and strong. [00:27] elopio: uhh, no worries. [00:27] didn't realyl do much to help :) [07:42] in Your first Autopilot test, I am unable to install libautopilot-qt python-autopilot