From 8f69816401873dbeea8a13f4cc0faf77c2a38f62 Mon Sep 17 00:00:00 2001 From: Fabien LOISON Date: Mon, 2 Sep 2024 13:45:56 +0200 Subject: [PATCH] Added an env var to speedup the tests --- doc/env.rst | 7 +++++++ noxfile.py | 1 + rivalcfg/mouse.py | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/env.rst b/doc/env.rst index ec045102..5ab3cd4d 100644 --- a/doc/env.rst +++ b/doc/env.rst @@ -14,6 +14,12 @@ Usage:: RIVALCFG_DRY=1 +RIVALCFG_DEBUG_NO_COMMAND_DELAY +------------------------------- + +When set, this remove the delay between commands. This is only usefull to allow tests to run faster, you may not use this with real devices, they may hang or even crash. See :py:attr:`~rivalcfg.mouse.Mouse.command_delay`. + + RIVALCFG_PROFILE ---------------- @@ -26,3 +32,4 @@ Usage:: For example, to load the Rival 100 profile and list its CLI options:: RIVALCFG_PROFILE=1038:1702 RIVALCFG_DRY=1 rivalcfg --help + diff --git a/noxfile.py b/noxfile.py index 63c99f1b..bdbb9ec0 100644 --- a/noxfile.py +++ b/noxfile.py @@ -33,6 +33,7 @@ def test(session): "test", env={ "RIVALCFG_DRY": "1", + "RIVALCFG_DEBUG_NO_COMMAND_DELAY": "1", }, ) diff --git a/rivalcfg/mouse.py b/rivalcfg/mouse.py index c8aec6d2..a0a77db6 100644 --- a/rivalcfg/mouse.py +++ b/rivalcfg/mouse.py @@ -1,3 +1,4 @@ +import os import time from . import usbhid @@ -291,7 +292,8 @@ def _hid_write( raise ValueError("Invalid HID report type: %2x" % report_type) # Avoids sending multiple commands to quickly - time.sleep(self._command_approve_delay) + if "RIVALCFG_DEBUG_NO_COMMAND_DELAY" not in os.environ: + time.sleep(self._command_approve_delay) def __getattr__(self, name): # Handle every set_xxx methods generated from device's profiles