Comments (8)
The output is rather long. Here is the output up to the first assert error when run with pytest -vv
============================= test session starts =============================
platform win32 -- Python 3.11.3, pytest-7.1.3, pluggy-1.0.0 -- puterbot\.venv\Scripts\python.exe
cachedir: .pytest_cache
rootdir: puterbot
collecting ... collected 7 items
tests/puterbot/test_events.py::test_merge_consecutive_mouse_click_events FAILED [ 14%]
tests/puterbot/test_events.py::test_merge_consecutive_mouse_move_events FAILED [ 28%]
tests/puterbot/test_events.py::test_merge_consecutive_mouse_scroll_events FAILED [ 42%]
tests/puterbot/test_events.py::test_remove_redundant_mouse_move_events FAILED [ 57%]
tests/puterbot/test_events.py::test_merge_consecutive_keyboard_events FAILED [ 71%]
tests/puterbot/test_events.py::test_merge_consecutive_keyboard_events__grouped FAILED [ 85%]
tests/puterbot/test_events.py::test_discard_unused_events PASSED [100%]
================================== FAILURES ===================================
__________________ test_merge_consecutive_mouse_click_events __________________
def test_merge_consecutive_mouse_click_events():
if OVERRIDE_DOUBLE_CLICK_INTERVAL_SECONDS:
override_double_click_interval_seconds(
OVERRIDE_DOUBLE_CLICK_INTERVAL_SECONDS
)
double_click_interval_seconds = get_double_click_interval_seconds()
dt_short = double_click_interval_seconds / 10
dt_long = double_click_interval_seconds * 10
raw_events = [
*make_click_events(dt_long, button_name="right"),
# doubleclick
*make_click_events(dt_short),
*make_click_events(dt_long),
# doubleclick
*make_click_events(dt_short),
*make_click_events(dt_long),
*make_click_events(dt_long, button_name="right"),
# singleclick
*make_click_events(dt_long),
]
logger.info(f"raw_events=\n{pformat(rows2dicts(raw_events))}")
reset_timestamp()
expected_events = rows2dicts([
*make_click_events(dt_long, button_name="right"),
make_doubleclick_event(
dt_long,
lambda: [
*make_click_events(dt_short),
*make_click_events(dt_long),
],
),
make_doubleclick_event(
dt_long,
lambda: [
*make_click_events(dt_short),
*make_click_events(dt_long),
],
),
*make_click_events(dt_long, button_name="right"),
make_singleclick_event(
dt_long,
lambda: [
*make_click_events(dt_long),
]
),
])
logger.info(f"expected_events=\n{pformat(expected_events)}")
actual_events = rows2dicts(
merge_consecutive_mouse_click_events(raw_events)
)
logger.info(f"actual_events=\n{pformat(actual_events)}")
> assert expected_events == actual_events
E AssertionError: assert [{'mouse_button_name': 'right',\n 'mouse_pressed': True,\n 'name': 'click',\n 'timestamp': 0.0},\n {'mouse_button_name': 'right',\n 'mouse_pressed': False,\n 'name': 'click',\n 'timestamp': 0.275},\n {'children': [{'mouse_pressed': True, 'timestamp': 5.775},\n {'mouse_pressed': False, 'timestamp': 6.050000000000001},\n {'mouse_pressed': True, 'timestamp': 6.105},\n {'mouse_pressed': False, 'timestamp': 6.380000000000001}],\n 'mouse_button_name': 'left',\n 'name': 'doubleclick',\n 'timestamp': 5.775},\n {'children': [{'mouse_pressed': True, 'timestamp': 11.880000000000003},\n {'mouse_pressed': False, 'timestamp': 12.155000000000003},\n {'mouse_pressed': True, 'timestamp': 12.210000000000003},\n {'mouse_pressed': False, 'timestamp': 12.485000000000003}],\n 'mouse_button_name': 'left',\n 'name': 'doubleclick',\n 'timestamp': 11.275},\n {'mouse_button_name': 'right',\n 'mouse_pressed': True,\n 'name': 'click',\n 'timestamp': 16.775},\n {'mouse_button_name': 'right',\n 'mouse_pressed': False,\n 'name': 'click',\n 'timestamp': 17.049999999999997},\n {'children': [{'mouse_pressed': True, 'timestamp': 23.76},\n {'mouse_pressed': False, 'timestamp': 24.035}],\n 'mouse_button_name': 'left',\n 'name': 'singleclick',\n 'timestamp': 22.549999999999997}] == [{'mouse_button_name': 'right',\n 'mouse_pressed': True,\n 'name': 'click',\n 'timestamp': 0.0},\n {'mouse_button_name': 'right',\n 'mouse_pressed': False,\n 'name': 'click',\n 'timestamp': 0.275},\n {'children': [{'mouse_pressed': True, 'timestamp': 5.775},\n {'mouse_pressed': False, 'timestamp': 6.050000000000001},\n {'mouse_pressed': True, 'timestamp': 6.105},\n {'mouse_pressed': False, 'timestamp': 6.380000000000001}],\n 'mouse_button_name': 'left',\n 'name': 'doubleclick',\n 'timestamp': 5.775},\n {'children': [{'mouse_pressed': True, 'timestamp': 11.88},\n {'mouse_pressed': False, 'timestamp': 12.155000000000001},\n {'mouse_pressed': True, 'timestamp': 12.21},\n {'mouse_pressed': False, 'timestamp': 12.485000000000001}],\n 'mouse_button_name': 'left',\n 'name': 'doubleclick',\n 'timestamp': 11.275},\n {'mouse_button_name': 'right',\n 'mouse_pressed': True,\n 'name': 'click',\n 'timestamp': 16.775},\n {'mouse_button_name': 'right',\n 'mouse_pressed': False,\n 'name': 'click',\n 'timestamp': 17.049999999999997},\n {'children': [{'mouse_pressed': True, 'timestamp': 23.759999999999998},\n {'mouse_pressed': False, 'timestamp': 24.034999999999997}],\n 'mouse_button_name': 'left',\n 'name': 'singleclick',\n 'timestamp': 22.549999999999997}]
E At index 3 diff: {'name': 'doubleclick', 'timestamp': 11.275, 'mouse_button_name': 'left', 'children': [{'timestamp': 11.880000000000003, 'mouse_pressed': True}, {'timestamp': 12.155000000000003, 'mouse_pressed': False}, {'timestamp': 12.210000000000003, 'mouse_pressed': True}, {'timestamp': 12.485000000000003, 'mouse_pressed': False}]} != {'name': 'doubleclick', 'timestamp': 11.275, 'mouse_button_name': 'left', 'children': [{'timestamp': 11.88, 'mouse_pressed': True}, {'timestamp': 12.155000000000001, 'mouse_pressed': False}, {'timestamp': 12.21, 'mouse_pressed': True}, {'timestamp': 12.485000000000001, 'mouse_pressed': False}]}
E Full diff:
E [
E {'mouse_button_name': 'right',
E 'mouse_pressed': True,
E 'name': 'click',
E 'timestamp': 0.0},
E {'mouse_button_name': 'right',
E 'mouse_pressed': False,
E 'name': 'click',
E 'timestamp': 0.275},
E {'children': [{'mouse_pressed': True, 'timestamp': 5.775},
E {'mouse_pressed': False, 'timestamp': 6.050000000000001},
E {'mouse_pressed': True, 'timestamp': 6.105},
E {'mouse_pressed': False, 'timestamp': 6.380000000000001}],
E 'mouse_button_name': 'left',
E 'name': 'doubleclick',
E 'timestamp': 5.775},
E - {'children': [{'mouse_pressed': True, 'timestamp': 11.88},
E + {'children': [{'mouse_pressed': True, 'timestamp': 11.880000000000003},
E ? +++++++++++++
E - {'mouse_pressed': False, 'timestamp': 12.155000000000001},
E ? ^
E + {'mouse_pressed': False, 'timestamp': 12.155000000000003},
E ? ^
E - {'mouse_pressed': True, 'timestamp': 12.21},
E + {'mouse_pressed': True, 'timestamp': 12.210000000000003},
E ? +++++++++++++
E - {'mouse_pressed': False, 'timestamp': 12.485000000000001}],
E ? ^
E + {'mouse_pressed': False, 'timestamp': 12.485000000000003}],
E ? ^
E 'mouse_button_name': 'left',
E 'name': 'doubleclick',
E 'timestamp': 11.275},
E {'mouse_button_name': 'right',
E 'mouse_pressed': True,
E 'name': 'click',
E 'timestamp': 16.775},
E {'mouse_button_name': 'right',
E 'mouse_pressed': False,
E 'name': 'click',
E 'timestamp': 17.049999999999997},
E - {'children': [{'mouse_pressed': True, 'timestamp': 23.759999999999998},
E ? ^^^^^^^^^^^^^^
E + {'children': [{'mouse_pressed': True, 'timestamp': 23.76},
E ? ^
E - {'mouse_pressed': False, 'timestamp': 24.034999999999997}],
E ? ^^^^^^^^^^^^^
E + {'mouse_pressed': False, 'timestamp': 24.035}],
E ? ^
E 'mouse_button_name': 'left',
E 'name': 'singleclick',
E 'timestamp': 22.549999999999997},
E ]
tests\puterbot\test_events.py:255: AssertionError
---------------------------- Captured stderr call -----------------------------
Failing tests:
=========================== short test summary info ===========================
FAILED tests/puterbot/test_events.py::test_merge_consecutive_mouse_click_events
FAILED tests/puterbot/test_events.py::test_merge_consecutive_mouse_move_events
FAILED tests/puterbot/test_events.py::test_merge_consecutive_mouse_scroll_events
FAILED tests/puterbot/test_events.py::test_remove_redundant_mouse_move_events
FAILED tests/puterbot/test_events.py::test_merge_consecutive_keyboard_events
FAILED tests/puterbot/test_events.py::test_merge_consecutive_keyboard_events__grouped
========================= 6 failed, 1 passed in 1.05s =========================
from openadapt.
from openadapt.
The tests now pass with it.
from openadapt.
Thanks @apgorton ! Can you please include the complete output so that we can see which tests are failing?
As a workaround try setting OVERRIDE_DOUBLE_CLICK_INTERVAL_SECONDS = 10
in https://github.com/MLDSAI/puterbot/blob/main/tests/puterbot/test_events.py#L30
from openadapt.
Thanks @apgorton ! Can you please include the complete output so that we can see which tests are failing?
As a workaround try setting
OVERRIDE_DOUBLE_CLICK_INTERVAL_SECONDS = 10
in https://github.com/MLDSAI/puterbot/blob/main/tests/puterbot/test_events.py#L30
I tried this, same result.
from openadapt.
Can you please clarify what you mean by "same result"? i.e. do you mean just that the tests are still failing, or that the log output is exactly the same?
Can you please set OVERRIDE_DOUBLE_CLICK_INTERVAL_SECONDS = 10
, run pytest
, and paste the results here?
from openadapt.
The timestamps are larger but the failure is the same. The difference between the timestamps being compared is roughly the same.
> assert expected_events == actual_events
E AssertionError: assert [{'mouse_button_name': 'right',\n 'mouse_pressed': True,\n 'name': 'click',\n 'timestamp': 0.0},\n {'mouse_button_name': 'right',\n 'mouse_pressed': False,\n 'name': 'click',\n 'timestamp': 0.275},\n {'children': [{'mouse_pressed': True, 'timestamp': 100.275},\n {'mouse_pressed': False, 'timestamp': 100.55000000000001},\n {'mouse_pressed': True, 'timestamp': 101.55000000000001},\n {'mouse_pressed': False, 'timestamp': 101.82500000000002}],\n 'mouse_button_name': 'left',\n 'name': 'doubleclick',\n 'timestamp': 100.275},\n {'children': [{'mouse_pressed': True, 'timestamp': 201.82500000000005},\n {'mouse_pressed': False, 'timestamp': 202.10000000000005},\n {'mouse_pressed': True, 'timestamp': 203.10000000000005},\n {'mouse_pressed': False, 'timestamp': 203.37500000000006}],\n 'mouse_button_name': 'left',\n 'name': 'doubleclick',\n 'timestamp': 200.275},\n {'mouse_button_name': 'right',\n 'mouse_pressed': True,\n 'name': 'click',\n 'timestamp': 300.275},\n {'mouse_button_name': 'right',\n 'mouse_pressed': False,\n 'name': 'click',\n 'timestamp': 300.54999999999995},\n {'children': [{'mouse_pressed': True, 'timestamp': 403.65000000000003},\n {'mouse_pressed': False, 'timestamp': 403.925}],\n 'mouse_button_name': 'left',\n 'name': 'singleclick',\n 'timestamp': 400.54999999999995}] == [{'mouse_button_name': 'right',\n 'mouse_pressed': True,\n 'name': 'click',\n 'timestamp': 0.0},\n {'mouse_button_name': 'right',\n 'mouse_pressed': False,\n 'name': 'click',\n 'timestamp': 0.275},\n {'children': [{'mouse_pressed': True, 'timestamp': 100.275},\n {'mouse_pressed': False, 'timestamp': 100.55000000000001},\n {'mouse_pressed': True, 'timestamp': 101.55000000000001},\n {'mouse_pressed': False, 'timestamp': 101.82500000000002}],\n 'mouse_button_name': 'left',\n 'name': 'doubleclick',\n 'timestamp': 100.275},\n {'children': [{'mouse_pressed': True, 'timestamp': 201.82500000000002},\n {'mouse_pressed': False, 'timestamp': 202.10000000000002},\n {'mouse_pressed': True, 'timestamp': 203.10000000000002},\n {'mouse_pressed': False, 'timestamp': 203.37500000000003}],\n 'mouse_button_name': 'left',\n 'name': 'doubleclick',\n 'timestamp': 200.275},\n {'mouse_button_name': 'right',\n 'mouse_pressed': True,\n 'name': 'click',\n 'timestamp': 300.275},\n {'mouse_button_name': 'right',\n 'mouse_pressed': False,\n 'name': 'click',\n 'timestamp': 300.54999999999995},\n {'children': [{'mouse_pressed': True, 'timestamp': 403.65},\n {'mouse_pressed': False, 'timestamp': 403.92499999999995}],\n 'mouse_button_name': 'left',\n 'name': 'singleclick',\n 'timestamp': 400.54999999999995}]
E At index 3 diff: {'name': 'doubleclick', 'timestamp': 200.275, 'mouse_button_name': 'left', 'children': [{'timestamp': 201.82500000000005, 'mouse_pressed': True}, {'timestamp': 202.10000000000005, 'mouse_pressed': False}, {'timestamp': 203.10000000000005, 'mouse_pressed': True}, {'timestamp': 203.37500000000006, 'mouse_pressed': False}]} != {'name': 'doubleclick', 'timestamp': 200.275, 'mouse_button_name': 'left', 'children': [{'timestamp': 201.82500000000002, 'mouse_pressed': True}, {'timestamp': 202.10000000000002, 'mouse_pressed': False}, {'timestamp': 203.10000000000002, 'mouse_pressed': True}, {'timestamp': 203.37500000000003, 'mouse_pressed': False}]}
E Full diff:
E [
E {'mouse_button_name': 'right',
E 'mouse_pressed': True,
E 'name': 'click',
E 'timestamp': 0.0},
E {'mouse_button_name': 'right',
E 'mouse_pressed': False,
E 'name': 'click',
E 'timestamp': 0.275},
E {'children': [{'mouse_pressed': True, 'timestamp': 100.275},
E {'mouse_pressed': False, 'timestamp': 100.55000000000001},
E {'mouse_pressed': True, 'timestamp': 101.55000000000001},
E {'mouse_pressed': False, 'timestamp': 101.82500000000002}],
E 'mouse_button_name': 'left',
E 'name': 'doubleclick',
E 'timestamp': 100.275},
E - {'children': [{'mouse_pressed': True, 'timestamp': 201.82500000000002},
E ? ^
E + {'children': [{'mouse_pressed': True, 'timestamp': 201.82500000000005},
E ? ^
E - {'mouse_pressed': False, 'timestamp': 202.10000000000002},
E ? ^
E + {'mouse_pressed': False, 'timestamp': 202.10000000000005},
E ? ^
E - {'mouse_pressed': True, 'timestamp': 203.10000000000002},
E ? ^
E + {'mouse_pressed': True, 'timestamp': 203.10000000000005},
E ? ^
E - {'mouse_pressed': False, 'timestamp': 203.37500000000003}],
E ? ^
E + {'mouse_pressed': False, 'timestamp': 203.37500000000006}],
E ? ^
E 'mouse_button_name': 'left',
E 'name': 'doubleclick',
E 'timestamp': 200.275},
E {'mouse_button_name': 'right',
E 'mouse_pressed': True,
E 'name': 'click',
E 'timestamp': 300.275},
E {'mouse_button_name': 'right',
E 'mouse_pressed': False,
E 'name': 'click',
E 'timestamp': 300.54999999999995},
E - {'children': [{'mouse_pressed': True, 'timestamp': 403.65},
E + {'children': [{'mouse_pressed': True, 'timestamp': 403.65000000000003},
E ? ++++++++++++
E - {'mouse_pressed': False, 'timestamp': 403.92499999999995}],
E ? -----------
E + {'mouse_pressed': False, 'timestamp': 403.925}],
E 'mouse_button_name': 'left',
E 'name': 'singleclick',
E 'timestamp': 400.54999999999995},
E ]
from openadapt.
Thank you! Looks like a floating point issue. Easiest fix is just to truncate timestamps to e.g. 6 decimal places.
e.g. implement a function truncate_timestamp(events)
, then modify all the tests in test_events.py
to process expected_events
and actual_events
with it.
from openadapt.
Related Issues (20)
- Store application logs HOT 1
- [Bug]: not bound to a Session; lazy load operation of attribute 'action_event' cannot proceed HOT 5
- Loading / Splash screen
- [Bug]: hide fixture recordings in dashboard HOT 2
- [Bug]: database contains recordings from previous versions HOT 2
- [Bug]: Failed to execute script 'entrypoint' due to unhandled exception: 'NoneType' has no attribute 'write' HOT 4
- [Bug]: `WindowEvent` race condition HOT 3
- [Bug]: mouse positions on Windows are not accurate HOT 2
- Handle similar segments HOT 2
- [Bug]: searching for deleted file while replaying
- Dashboard: delete parent events HOT 5
- [Bug]: Nonetype object has no attribute write HOT 3
- Support for Efficient Multi-Window Accessibility Tree Capture HOT 1
- [Bug]: VanillaReplayStategy returns unexpected keyword argument instructions
- [Bug]: VanillaReplayStategy returns KeyError
- [Bug]: handle OpenAI API image errors
- Wait for action effect to complete before attempting to get next action
- [Bug]: Vanilla replay strategy fails with below error HOT 2
- [Bug]: ValueError in `openadapt\video.py:151` - Specified pixel format rgb24 is invalid or not supported HOT 4
- [Bug]: `QWindowsContext: OleInitialize() failed` error on running: `python -m openadapt.app.visualize` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openadapt.