Пример #1
0
 def test_str(self):
     p = parameters.Parameters(foo="bar")
     assert str(p) == textwrap.dedent("""
     Parameters({
         "foo": "bar"
     })
     """).strip()
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
 def test_get(self):
     p = parameters.Parameters(foo="bar")
     assert p["foo"].value == "bar"
Пример #5
0
 def test_repr(self):
     p = parameters.Parameters(foo="bar", bar="boo")
     assert repr(p) == "Parameters(2 values)"
Пример #6
0
 def test_len(self):
     p = parameters.Parameters(foo="bar")
     assert len(p) == 1
Пример #7
0
 def test_iter(self):
     p = parameters.Parameters(foo="bar")
     assert len(list(p)) == 1
Пример #8
0
 def test_del(self):
     p = parameters.Parameters(foo="bar")
     del p["foo"]
     assert "foo" not in p