-
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 7 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 | ||
|
||
|
@@ -58,6 +60,28 @@ def import_module_from_file(filename): | |
return importlib.import_module(module_name) | ||
|
||
|
||
def allx(iterable): | ||
"""Same as the built-in all, except that it returns :class:`False` if | ||
``iterable`` is empty. | ||
""" | ||
|
||
# Generators must be treated specially, because there is no way to get | ||
# their size without consuming their elements. | ||
if isinstance(iterable, types.GeneratorType): | ||
try: | ||
head = next(iterable) | ||
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! |
||
else: | ||
return all(itertools.chain([head], iterable)) | ||
|
||
if not isinstance(iterable, collections.abc.Iterable): | ||
raise TypeError("'%s' object is not iterable" % | ||
iterable.__class__.__name__) | ||
|
||
return all(iterable) if iterable else False | ||
|
||
|
||
def decamelize(s): | ||
"""Decamelize the string ``s``. | ||
|
||
|
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.
I suggest replacing the lambdas altogether here in favour of a closure: