Two test failures due to arguments having incorrect types
mgorny opened this issue · comments
I've just noticed that we weren't running the tests correctly in Gentoo, and we haven't been testing the C extension. After fixing that, I see two test failures:
FAILED test/test_box.py::TestBox::test_box_kwargs_should_not_be_included - TypeError: Argument 'box_recast' has incorrect type (expected dict, got bool)
FAILED test/test_box.py::TestBox::test_box_namespace - TypeError: Argument 'box_namespace' has incorrect type (expected tuple, got bool)
I can reproduce them with 7.0.1 release and git develop
@ 1025c0a.
To reproduce:
python3.10 -m venv .venv
. .venv/bin/activate
pip install -r requirements-dev.txt -r requirements-test.txt
pip install -e .
python -m pytest -vv
Full traceback:
============================================================== FAILURES ===============================================================
___________________________________________ TestBox.test_box_kwargs_should_not_be_included ____________________________________________
self = <test.test_box.TestBox object at 0x7f1436459b70>
def test_box_kwargs_should_not_be_included(self):
params = {
"default_box": True,
"default_box_attr": True,
"conversion_box": True,
"frozen_box": True,
"camel_killer_box": True,
"box_safe_prefix": "x",
"box_duplicates": "error",
"default_box_none_transform": True,
"box_dots": True,
"modify_tuples_box": True,
"box_intact_types": (),
"box_recast": True,
}
> bx = Box(**params)
E TypeError: Argument 'box_recast' has incorrect type (expected dict, got bool)
test/test_box.py:1341: TypeError
_____________________________________________________ TestBox.test_box_namespace ______________________________________________________
self = <test.test_box.TestBox object at 0x7f1436458fa0>
def test_box_namespace(self):
bx = Box(default_box=True)
assert bx._box_config["box_namespace"] == ()
bx.a.b.c = 5
assert bx.a._box_config["box_namespace"] == ("a",)
assert bx.a.b._box_config["box_namespace"] == ("a", "b")
bx.x = {"y": {"z": 5}}
assert bx.x._box_config["box_namespace"] == ("x",)
assert bx.x.y._box_config["box_namespace"] == ("x", "y")
bx[None][1][2] = 3
assert bx[None][1]._box_config["box_namespace"] == (None, 1)
for modified_box in [
bx.a + bx.x,
bx.a - bx.x,
bx.a | bx.x,
]:
assert modified_box._box_config["box_namespace"] == ()
assert modified_box.b._box_config["box_namespace"] == ("b",)
assert modified_box.y._box_config["box_namespace"] == ("y",)
bx.modified = {}
assert bx.modified._box_config["box_namespace"] == ("modified",)
bx.modified += bx.a
assert bx.modified.b._box_config["box_namespace"] == ("modified", "b")
bx.modified |= bx.x
assert bx.modified.y._box_config["box_namespace"] == ("modified", "y")
bx.modified -= bx.a
assert bx.modified._box_config["box_namespace"] == ("modified",)
> bx2 = Box(box_namespace=False)
E TypeError: Argument 'box_namespace' has incorrect type (expected tuple, got bool)
test/test_box.py:1430: TypeError
======================================================= short test summary info =======================================================
FAILED test/test_box.py::TestBox::test_box_kwargs_should_not_be_included - TypeError: Argument 'box_recast' has incorrect type (expected dict, got bool)
FAILED test/test_box.py::TestBox::test_box_namespace - TypeError: Argument 'box_namespace' has incorrect type (expected tuple, got bool)
==================================================== 2 failed, 144 passed in 0.64s ====================================================
Unless I'm mistaken, it seems that the tests are passing incorrect argument types per the signatures.
Thanks for the info! I have not been able to replicate that on Windows or Ubuntu 22 WSL.
However the subs do need updated and flushed out better, and make sure mypy is updated and good to go so I will make those changes (which will update these tests) for the next version.
Updated in 7.1.0, hopefully fixed, but I was not able to re-create issue to verify. Let me know if there is still any issues!
Thanks, it looks good now!