Comments (3)
Waiting for a condition to continue test case execution (snippet 1) is fundamentally different from running an assertion (snippet 2).
A condition is something which must be met, but may take a while to do so due to asynchonously tasks needing to finish in background. It's main purpose is synchonization. The callable passed is polled until returning true
. As self.assert...
methods don't return anything and would raise exceptions if condition is not meat they are not applicable in this context.
Conditions can be passed as dictionary. Maybe passing an optional error message can be implemented, which is displayed if timeout appears.
def test_something(self):
self.window.run_command("show_panel", {"panel": "console"})
yield {
"condition": lambda: self.window.active_panel() == "console",
"period": 100,
"timeout": 5000,
"timeout_message": "Console not activated"
}
from unittesting.
The callable passed is polled until returning true. As self.assert... methods don't return anything and would raise exceptions if condition is not meat they are not applicable in this context.
My proposal was to keep catching AssertionError
as a synchronization mechanism as in:
def call_until(assert_call, timeout=5):
stop_at = time.monotonic() + timeout
while True:
try:
return assert_call()
except AssertionError:
if time.monotonic() > stop_at:
raise TimeoutError
time.sleep(0.01)
from unittesting.
Interesting idea. When assuming assertions to always return None
and normal conditions only True
or False
, it should be doable with hopefully low risk on breaking anyones test cases.
Was too focused on "missing a message" and the aspect of conditions vs. assertions, before.
from unittesting.
Related Issues (20)
- Run hook on failed test
- macOS CI failing on install HOT 5
- disable CircleCi HOT 4
- sporadic macOS 11 CI failing to launch on GitHub Actions with kLSNoExecutableErr
- MacOS action hangs HOT 6
- GitHub Actions build with Ubuntu runner failing with 404 on xz-utils HOT 2
- GH actions fail to download binaries HOT 2
- GH Actions: timeout during Package Control installation HOT 9
- Ability to run single test methods or classes HOT 8
- Question: My plugin didn't generate files as it should HOT 2
- Test Current File ImportError failed to imports tests (ST4) HOT 1
- GitHub Actions macOS timeout installing Package Control HOT 3
- Coverage not generating HOT 23
- AttributeError: 'PackageManager' object has no attribute '_is_dependency'
- Coverage fails on MacOS / ST4
- ST3 regression HOT 2
- TypeError logging missing library HOT 4
- [MacOS, GithubActions]Timeout: Fail to install Package Control. HOT 2
- Enable warnings by default 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 unittesting.