Comments (7)
https://testslide.readthedocs.io/en/1.5.0/testslide_dsl/skip_and_focus/index.html#skip
xexample is the way to go for unconditional skip. However it is just regular Python, this also works:
if should_have_example:
@context.example
def whatever(self):
Real world example https://github.com/facebookincubator/TestSlide/blob/master/tests/mock_callable_testslide.py#L179.
I suppose we could have some syntax sugar for that like:
@context.example(skip=should_skip)
But it seems no to be strictly needed.
What do you think?
from testslide.
The daily use case for my work is that we have some test examples that only runs on GPU CUDA devices.
But CI could pick building and testing our project in either environment, ones with CPU+GPU or ones that has CPU only.
We used @unittest.skipUnless(cuda.is_available())
a lot.
In TestSlide, we will have to write this to circumvent
If not cuda.is_available():
return
And, more importantly, the test runner will not remind me that the test is skipped.
from testslide.
@fornellas Thanks, I will try this way. Conditionally declare contexts and examples.
from testslide.
Cool. I'm closing this then, as it seems you have a way for conditionally skip. Feel free to reopen if you feel like it deserves some syntax sugar.
from testslide.
After trying it out, I feel it's still needed.
Because it would be great to have a "SKIP" item in test runner results, just like @context.xexample does.
In short, skipped tests are worth being noticed!
For example, I have a lot of tests that must be skipped when running on a machine without GPU avaiable.
With conditional test example declaration as you suggested above would silently hide these examples.
However, for a new developer onboarding to my tests, he/she might be unware of that, when running on a CPU only machine, there are many GPU tests being explicitly skipped.
If these skipped tests could be noticed by new developmers, they might find better test environment.
from testslide.
NP. So, how do you think the syntax should go?
@context.example(skip=should_skip)
Is it ok like this?
from testslide.
Thanks for opening it.
It looks great.
One thing worth noticing is that, after searching in my company's repo, I noticed that @unittest.skipUnless(condition)
has 2X usage than @unittest.skip(condition)
.
That means with this simple syntax, we need to expect a lot of
@context.example(skip=not should_run_example)
from testslide.
Related Issues (20)
- Add linter to ensure Copyright header on files
- BUG: Leaked task detection triggers for cancelled tasks HOT 2
- Context methods can't be async and are being quietly ignored
- StrictMock validations broken when used via inheritance.
- Improve Coroutine value error error message
- patch_attribute issue with Python 3.10 HOT 1
- Testslide runner not playing well with unittest.subtests HOT 1
- [RFC] [runner] Use Pattern.search() instead of Pattern.match() for "--filter-regex" behavior HOT 1
- Make Gitlab CI running tests/linting also for pull requests. HOT 1
- add assert_called_times(times:int) for callable mocks HOT 1
- `and_assert_not_called` shouldn't need any behaviour defined beforehand HOT 2
- Make to_return_values work for patch attribute HOT 1
- Cannot mock method with signature `def ...(...) -> Awaitable[...]` due to TypeCheckError
- Windows support HOT 1
- Cannot type check with `from __future__ import annotations`
- Can't mock a @property without calling it? HOT 5
- AttributeError for asyncio.coroutines.CoroWrapper in Python 3.11.0 HOT 1
- Test failures with Pygments 2.14
- Request: Container Matchers HOT 3
- Test failures with python 3.11+
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 testslide.