Add make_simple_namespace function and tests (#2840)

Co-authored-by: Jouke Witteveen <j.witteveen@cosine.nl>
This commit is contained in:
Jouke Witteveen
2021-08-26 17:04:22 +02:00
committed by GitHub
parent c8ce4b8df8
commit 031a700dfd
4 changed files with 78 additions and 1 deletions

View File

@@ -99,6 +99,19 @@ def test_dict(capture, doc):
assert m.dict_keyword_constructor() == {"x": 1, "y": 2, "z": 3}
def test_tuple():
assert m.get_tuple() == (42, None, "spam")
@pytest.mark.skipif("env.PY2")
def test_simple_namespace():
ns = m.get_simple_namespace()
assert ns.attr == 42
assert ns.x == "foo"
assert ns.right == 2
assert not hasattr(ns, "wrong")
def test_str(doc):
assert m.str_from_string().encode().decode() == "baz"
assert m.str_from_bytes().encode().decode() == "boo"