-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter out tests with no programming environments #319
Changes from 2 commits
8d47856
771c641
142f89a
4f4377c
e0c343b
b817683
e1e5a43
eb34e05
0d14066
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import collections | ||
import importlib | ||
import importlib.util | ||
import itertools | ||
import os | ||
import re | ||
import sys | ||
import types | ||
|
||
from collections import UserDict | ||
|
||
|
@@ -54,6 +56,28 @@ def import_module_from_file(filename): | |
return importlib.import_module(module_name) | ||
|
||
|
||
def allx(iterable): | ||
"""Return ``True`` if all elements of the `iterable` are true. If | ||
iterable is empty or ``None`` return ``False``. | ||
|
||
.. versionadded:: 2.13 | ||
|
||
""" | ||
|
||
# Check if iterable is an empty generator | ||
if isinstance(iterable, types.GeneratorType): | ||
try: | ||
first_item = next(iterable) | ||
return all(itertools.chain([first_item], iterable)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better put this in the |
||
except StopIteration: | ||
return False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't understand all this fuss here. Why a check of
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we do not want to accept empty generators. Is there any other way to check that a generator is empty? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by "empty generator"? A generator is a generator, i.e., an iterable, even if it doesn't produce any values. Your unit tests should pass fine using my proposal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean a generator like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now, I get what you are trying to do. The comment above the code is really misleading... Please change it with sth more precise! |
||
|
||
if not iterable: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not enough. If |
||
return False | ||
|
||
return all(iterable) | ||
|
||
|
||
def decamelize(s): | ||
"""Decamelize the string ``s``. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,7 @@ | |
import itertools | ||
import re | ||
|
||
import reframe.utility as util | ||
from reframe.core.deferrable import deferrable, evaluate | ||
from reframe.core.exceptions import SanityError | ||
|
||
|
@@ -116,6 +117,16 @@ def all(iterable): | |
return builtins.all(iterable) | ||
|
||
|
||
@deferrable | ||
def allx(iterable): | ||
"""Replacement for the :func:`allx() <reframe.utility.allx>` function. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The documentation of |
||
|
||
.. versionadded:: 2.13 | ||
|
||
""" | ||
return util.allx(iterable) | ||
|
||
|
||
@deferrable | ||
def any(iterable): | ||
"""Replacement for the built-in :func:`any() <python:any>` function.""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all()
: Same as the built-inall
, except that it returnsFalse
ifiterable
is empty.all()
ifiterable
is not empty, which means, we should raiseTypeError
if the argument isNone
. Pay attention to have fully compatible behaviour.iterable
.None
,True
andFalse
must be formatted as:class:`None`
,:class:`True`
etc.