def test_str(self): p = parameters.Parameters(foo="bar") assert str(p) == textwrap.dedent(""" Parameters({ "foo": "bar" }) """).strip()
def test_all(self): p = parameters.Parameters(**{ "foo.foo": "bar", "foo.foobar": "baz", "bar": "bazoo", }) assert len(p.all()) == 3 assert len(p.all("foo.")) == 2 assert len(p.all("foo.foo")) == 1
def test_set(self): p = parameters.Parameters() p["foo"] = "bar" assert p["foo"].value == "bar" p["baz"] = parameters.Parameter("baz", "qux") assert p["baz"].value == "qux" with pytest.raises(ValueError): p["qux"] = parameters.Parameter("other", "quux") with pytest.raises(TypeError): p["qux"] = 42
def test_get(self): p = parameters.Parameters(foo="bar") assert p["foo"].value == "bar"
def test_repr(self): p = parameters.Parameters(foo="bar", bar="boo") assert repr(p) == "Parameters(2 values)"
def test_len(self): p = parameters.Parameters(foo="bar") assert len(p) == 1
def test_iter(self): p = parameters.Parameters(foo="bar") assert len(list(p)) == 1
def test_del(self): p = parameters.Parameters(foo="bar") del p["foo"] assert "foo" not in p