feat: new alternate syntax and switch to black + isort (yeah, maybe not the best time, but that is done).
This commit is contained in:
@ -11,7 +11,7 @@ class NoOptConfigurable(Configurable):
|
||||
|
||||
class MyConfigurable(Configurable):
|
||||
required_str = Option(str)
|
||||
default_str = Option(str, default='foo')
|
||||
default_str = Option(str, default="foo")
|
||||
integer = Option(int, required=False)
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ class MyHarderConfigurable(MyConfigurable):
|
||||
|
||||
|
||||
class MyBetterConfigurable(MyConfigurable):
|
||||
required_str = Option(str, required=False, default='kaboom')
|
||||
required_str = Option(str, required=False, default="kaboom")
|
||||
|
||||
|
||||
class MyConfigurableUsingPositionalOptions(MyConfigurable):
|
||||
@ -35,7 +35,7 @@ def test_missing_required_option_error():
|
||||
|
||||
with pytest.raises(TypeError) as exc:
|
||||
MyConfigurable(_final=True)
|
||||
assert exc.match('missing 1 required option:')
|
||||
assert exc.match("missing 1 required option:")
|
||||
|
||||
|
||||
def test_missing_required_options_error():
|
||||
@ -44,29 +44,29 @@ def test_missing_required_options_error():
|
||||
|
||||
with pytest.raises(TypeError) as exc:
|
||||
MyHarderConfigurable(_final=True)
|
||||
assert exc.match('missing 2 required options:')
|
||||
assert exc.match("missing 2 required options:")
|
||||
|
||||
|
||||
def test_extraneous_option_error():
|
||||
with pytest.raises(TypeError) as exc:
|
||||
MyConfigurable(required_str='foo', hello='world')
|
||||
assert exc.match('got 1 unexpected option:')
|
||||
MyConfigurable(required_str="foo", hello="world")
|
||||
assert exc.match("got 1 unexpected option:")
|
||||
|
||||
|
||||
def test_extraneous_options_error():
|
||||
with pytest.raises(TypeError) as exc:
|
||||
MyConfigurable(required_str='foo', hello='world', acme='corp')
|
||||
assert exc.match('got 2 unexpected options:')
|
||||
MyConfigurable(required_str="foo", hello="world", acme="corp")
|
||||
assert exc.match("got 2 unexpected options:")
|
||||
|
||||
|
||||
def test_defaults():
|
||||
o = MyConfigurable(required_str='hello')
|
||||
o = MyConfigurable(required_str="hello")
|
||||
|
||||
with inspect_node(o) as ni:
|
||||
assert not ni.partial
|
||||
|
||||
assert o.required_str == 'hello'
|
||||
assert o.default_str == 'foo'
|
||||
assert o.required_str == "hello"
|
||||
assert o.default_str == "foo"
|
||||
assert o.integer is None
|
||||
|
||||
|
||||
@ -76,30 +76,30 @@ def test_str_type_factory():
|
||||
with inspect_node(o) as ni:
|
||||
assert not ni.partial
|
||||
|
||||
assert o.required_str == '42'
|
||||
assert o.default_str == 'foo'
|
||||
assert o.required_str == "42"
|
||||
assert o.default_str == "foo"
|
||||
assert o.integer is None
|
||||
|
||||
|
||||
def test_int_type_factory():
|
||||
o = MyConfigurable(required_str='yo', default_str='bar', integer='42')
|
||||
o = MyConfigurable(required_str="yo", default_str="bar", integer="42")
|
||||
|
||||
with inspect_node(o) as ni:
|
||||
assert not ni.partial
|
||||
|
||||
assert o.required_str == 'yo'
|
||||
assert o.default_str == 'bar'
|
||||
assert o.required_str == "yo"
|
||||
assert o.default_str == "bar"
|
||||
assert o.integer == 42
|
||||
|
||||
|
||||
def test_bool_type_factory():
|
||||
o = MyHarderConfigurable(required_str='yes', also_required='True')
|
||||
o = MyHarderConfigurable(required_str="yes", also_required="True")
|
||||
|
||||
with inspect_node(o) as ni:
|
||||
assert not ni.partial
|
||||
|
||||
assert o.required_str == 'yes'
|
||||
assert o.default_str == 'foo'
|
||||
assert o.required_str == "yes"
|
||||
assert o.default_str == "foo"
|
||||
assert o.integer is None
|
||||
assert o.also_required is True
|
||||
|
||||
@ -110,22 +110,22 @@ def test_option_resolution_order():
|
||||
with inspect_node(o) as ni:
|
||||
assert not ni.partial
|
||||
|
||||
assert o.required_str == 'kaboom'
|
||||
assert o.default_str == 'foo'
|
||||
assert o.required_str == "kaboom"
|
||||
assert o.default_str == "foo"
|
||||
assert o.integer is None
|
||||
|
||||
|
||||
def test_option_positional():
|
||||
o = MyConfigurableUsingPositionalOptions('1', '2', '3', required_str='hello')
|
||||
o = MyConfigurableUsingPositionalOptions("1", "2", "3", required_str="hello")
|
||||
|
||||
with inspect_node(o) as ni:
|
||||
assert not ni.partial
|
||||
|
||||
assert o.first == '1'
|
||||
assert o.second == '2'
|
||||
assert o.third == '3'
|
||||
assert o.required_str == 'hello'
|
||||
assert o.default_str == 'foo'
|
||||
assert o.first == "1"
|
||||
assert o.second == "2"
|
||||
assert o.third == "3"
|
||||
assert o.required_str == "hello"
|
||||
assert o.default_str == "foo"
|
||||
assert o.integer is None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user