[qa] covers __main__, and formating.
This commit is contained in:
@ -79,7 +79,9 @@ class Container(dict):
|
|||||||
if not name in self:
|
if not name in self:
|
||||||
if default:
|
if default:
|
||||||
return default
|
return default
|
||||||
raise MissingServiceImplementationError('Cannot resolve service {!r} using provided service collection.'.format(name))
|
raise MissingServiceImplementationError(
|
||||||
|
'Cannot resolve service {!r} using provided service collection.'.format(name)
|
||||||
|
)
|
||||||
value = super().get(name)
|
value = super().get(name)
|
||||||
if isinstance(value, types.LambdaType):
|
if isinstance(value, types.LambdaType):
|
||||||
value = value(self)
|
value = value(self)
|
||||||
|
|||||||
@ -57,5 +57,6 @@ class ProhibitedOperationError(RuntimeError):
|
|||||||
class ConfigurationError(Exception):
|
class ConfigurationError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MissingServiceImplementationError(KeyError):
|
class MissingServiceImplementationError(KeyError):
|
||||||
pass
|
pass
|
||||||
@ -8,6 +8,7 @@ from bonobo.plugins import get_enhancers
|
|||||||
from bonobo.util.errors import print_error
|
from bonobo.util.errors import print_error
|
||||||
from bonobo.util.objects import Wrapper, get_name
|
from bonobo.util.objects import Wrapper, get_name
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def recoverable(error_handler):
|
def recoverable(error_handler):
|
||||||
try:
|
try:
|
||||||
@ -15,6 +16,7 @@ def recoverable(error_handler):
|
|||||||
except Exception as exc: # pylint: disable=broad-except
|
except Exception as exc: # pylint: disable=broad-except
|
||||||
error_handler(exc, traceback.format_exc())
|
error_handler(exc, traceback.format_exc())
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def unrecoverable(error_handler):
|
def unrecoverable(error_handler):
|
||||||
try:
|
try:
|
||||||
@ -23,6 +25,7 @@ def unrecoverable(error_handler):
|
|||||||
error_handler(exc, traceback.format_exc())
|
error_handler(exc, traceback.format_exc())
|
||||||
raise # raise unrecoverableerror from x ?
|
raise # raise unrecoverableerror from x ?
|
||||||
|
|
||||||
|
|
||||||
class LoopingExecutionContext(Wrapper):
|
class LoopingExecutionContext(Wrapper):
|
||||||
alive = True
|
alive = True
|
||||||
PERIOD = 0.25
|
PERIOD = 0.25
|
||||||
|
|||||||
@ -73,7 +73,7 @@ def _count_counter(self, context):
|
|||||||
class PrettyPrinter(Configurable):
|
class PrettyPrinter(Configurable):
|
||||||
def call(self, *args, **kwargs):
|
def call(self, *args, **kwargs):
|
||||||
for i, (item, value) in enumerate(itertools.chain(enumerate(args), kwargs.items())):
|
for i, (item, value) in enumerate(itertools.chain(enumerate(args), kwargs.items())):
|
||||||
print(' ' if i else '•', item, '=', str(value).strip().replace('\n', '\n'+CLEAR_EOL), CLEAR_EOL)
|
print(' ' if i else '•', item, '=', str(value).strip().replace('\n', '\n' + CLEAR_EOL), CLEAR_EOL)
|
||||||
|
|
||||||
|
|
||||||
pprint = Tee(_pprint)
|
pprint = Tee(_pprint)
|
||||||
|
|||||||
@ -37,11 +37,10 @@ def print_error(exc, trace, context=None, method=None):
|
|||||||
' (in {}{})'.format(type(context).__name__, '.{}()'.format(method) if method else '') if context else '',
|
' (in {}{})'.format(type(context).__name__, '.{}()'.format(method) if method else '') if context else '',
|
||||||
Style.RESET_ALL,
|
Style.RESET_ALL,
|
||||||
'\n',
|
'\n',
|
||||||
indent(_get_error_message(exc), prefix+Style.BRIGHT),
|
indent(_get_error_message(exc), prefix + Style.BRIGHT),
|
||||||
Style.RESET_ALL,
|
Style.RESET_ALL,
|
||||||
sep='',
|
sep='',
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
print(prefix, file=sys.stderr)
|
print(prefix, file=sys.stderr)
|
||||||
print(indent(trace, prefix, predicate=lambda line: True), file=sys.stderr)
|
print(indent(trace, prefix, predicate=lambda line: True), file=sys.stderr)
|
||||||
|
|
||||||
|
|||||||
36
setup.py
36
setup.py
@ -42,43 +42,41 @@ else:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='bonobo',
|
name='bonobo',
|
||||||
description=
|
description=('Bonobo, a simple, modern and atomic extract-transform-load toolkit for '
|
||||||
('Bonobo, a simple, modern and atomic extract-transform-load toolkit for '
|
'python 3.5+.'),
|
||||||
'python 3.5+.'),
|
|
||||||
license='Apache License, Version 2.0',
|
license='Apache License, Version 2.0',
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'colorama >=0.3,<1.0', 'fs >=2.0,<3.0', 'psutil >=5.2,<6.0',
|
'colorama >=0.3,<1.0', 'fs >=2.0,<3.0', 'psutil >=5.2,<6.0', 'requests >=2.0,<3.0', 'stevedore >=1.21,<2.0'
|
||||||
'requests >=2.0,<3.0', 'stevedore >=1.21,<2.0'
|
|
||||||
],
|
],
|
||||||
version=version,
|
version=version,
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
classifiers=classifiers,
|
classifiers=classifiers,
|
||||||
packages=find_packages(exclude=['ez_setup', 'example', 'test']),
|
packages=find_packages(exclude=['ez_setup', 'example', 'test']),
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
data_files=[('share/jupyter/nbextensions/bonobo-jupyter', [
|
data_files=[
|
||||||
'bonobo/ext/jupyter/static/extension.js',
|
(
|
||||||
'bonobo/ext/jupyter/static/index.js',
|
'share/jupyter/nbextensions/bonobo-jupyter', [
|
||||||
'bonobo/ext/jupyter/static/index.js.map'
|
'bonobo/ext/jupyter/static/extension.js', 'bonobo/ext/jupyter/static/index.js',
|
||||||
])],
|
'bonobo/ext/jupyter/static/index.js.map'
|
||||||
|
]
|
||||||
|
)
|
||||||
|
],
|
||||||
extras_require={
|
extras_require={
|
||||||
'dev': [
|
'dev': [
|
||||||
'coverage >=4,<5', 'pylint >=1,<2', 'pytest >=3,<4',
|
'coverage >=4,<5', 'pylint >=1,<2', 'pytest >=3,<4', 'pytest-cov >=2,<3', 'pytest-timeout >=1,<2', 'sphinx',
|
||||||
'pytest-cov >=2,<3', 'pytest-timeout >=1,<2', 'sphinx',
|
|
||||||
'sphinx_rtd_theme', 'yapf'
|
'sphinx_rtd_theme', 'yapf'
|
||||||
],
|
],
|
||||||
'jupyter': ['jupyter >=1.0,<1.1', 'ipywidgets >=6.0.0.beta5']
|
'jupyter': ['jupyter >=1.0,<1.1', 'ipywidgets >=6.0.0.beta5']
|
||||||
},
|
},
|
||||||
entry_points={
|
entry_points={
|
||||||
'bonobo.commands': [
|
'bonobo.commands': [
|
||||||
'init = bonobo.commands.init:register',
|
'init = bonobo.commands.init:register', 'run = bonobo.commands.run:register',
|
||||||
'run = bonobo.commands.run:register',
|
|
||||||
'version = bonobo.commands.version:register'
|
'version = bonobo.commands.version:register'
|
||||||
],
|
],
|
||||||
'console_scripts': ['bonobo = bonobo.commands:entrypoint'],
|
'console_scripts': ['bonobo = bonobo.commands:entrypoint'],
|
||||||
'edgy.project.features':
|
'edgy.project.features': ['bonobo = '
|
||||||
['bonobo = '
|
'bonobo.ext.edgy.project.feature:BonoboFeature']
|
||||||
'bonobo.ext.edgy.project.feature:BonoboFeature']
|
|
||||||
},
|
},
|
||||||
url='https://www.bonobo-project.org/',
|
url='https://www.bonobo-project.org/',
|
||||||
download_url='https://github.com/python-bonobo/bonobo/tarball/{version}'.
|
download_url='https://github.com/python-bonobo/bonobo/tarball/{version}'.format(version=version),
|
||||||
format(version=version), )
|
)
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
|
import runpy
|
||||||
|
import sys
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from bonobo import __version__, get_examples_path
|
from bonobo import __main__, __version__, get_examples_path
|
||||||
from bonobo.commands import entrypoint
|
from bonobo.commands import entrypoint
|
||||||
|
|
||||||
|
|
||||||
@ -10,7 +14,8 @@ def runner_entrypoint(*args):
|
|||||||
|
|
||||||
|
|
||||||
def runner_module(*args):
|
def runner_module(*args):
|
||||||
return entrypoint(list(args))
|
with patch.object(sys, 'argv', ['bonobo', *args]):
|
||||||
|
return runpy.run_path(__main__.__file__, run_name='__main__')
|
||||||
|
|
||||||
|
|
||||||
all_runners = pytest.mark.parametrize('runner', [runner_entrypoint, runner_module])
|
all_runners = pytest.mark.parametrize('runner', [runner_entrypoint, runner_module])
|
||||||
|
|||||||
Reference in New Issue
Block a user