Merge branch 'master' into develop

This commit is contained in:
Romain Dorgueil
2018-08-11 15:04:35 +02:00
45 changed files with 257 additions and 205 deletions

View File

@ -130,7 +130,21 @@ def test_requires():
assert svcargs["output"] == vcr.append
@pytest.mark.parametrize("services", [None, {}])
def test_constructor():
c1 = Container(foo='foo', bar='bar')
assert 2 == len(c1)
c2 = Container({'foo': 'foo', 'bar': 'bar'})
assert 2 == len(c2)
assert c1['foo'] == c2['foo']
assert c1['bar'] == c2['bar']
with pytest.raises(ValueError):
Container({'bar': 'bar'}, foo='foo')
@pytest.mark.parametrize('services', [None, {}])
def test_create_container_empty_values(services):
c = create_container(services)
assert len(c) == 2

View File

@ -63,9 +63,9 @@ class CsvReaderTest(Csv, ReaderTest, TestCase):
def test_output_type(self, context):
context.write_sync(EMPTY)
context.stop()
self.check_output(context, prepend=[("id", "name")])
self.check_output(context, prepend=[('id', 'name')])
@incontext(output_fields=("x", "y"), skip=1)
@incontext(output_fields=('x', 'y'), skip=1)
def test_output_fields(self, context):
context.write_sync(EMPTY)
context.stop()
@ -103,7 +103,7 @@ class CsvWriterTest(Csv, WriterTest, TestCase):
context.write_sync((L1, L2), (L3, L4))
context.stop()
assert self.readlines() == ("a,hey", "b,bee", "c,see", "d,dee")
assert self.readlines() == ('a,hey', 'b,bee', 'c,see', 'd,dee')
@incontext()
def test_nofields_multiple_args_length_mismatch(self, context):

View File

@ -14,6 +14,7 @@ FOOBAZ = {"foo": "baz"}
incontext = ConfigurableNodeTest.incontext
###
# Standard JSON Readers / Writers
###

View File

@ -5,6 +5,7 @@ from unittest.mock import patch
import pytest
from bonobo import settings
from bonobo.errors import ValidationError
TEST_SETTING = "TEST_SETTING"
@ -38,6 +39,15 @@ def test_setting():
s.clear()
assert s.get() == "hello"
s = settings.Setting(TEST_SETTING, default=0, validator=lambda x: x == 42)
with pytest.raises(ValidationError):
assert s.get() is 0
s.set(42)
with pytest.raises(ValidationError):
s.set(21)
def test_default_settings():
settings.clear_all()