Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two test failures due to arguments having incorrect types #257

Closed
mgorny opened this issue Aug 6, 2023 · 3 comments
Closed

Two test failures due to arguments having incorrect types #257

mgorny opened this issue Aug 6, 2023 · 3 comments

Comments

@mgorny
Copy link
Contributor

mgorny commented Aug 6, 2023

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.

cdgriffith added a commit that referenced this issue Aug 11, 2023
* Fixing #257 Two test failures due to arguments having incorrect types (thanks to Michał Górny)
* Fixing stub files to match latest code signatures
@cdgriffith
Copy link
Owner

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.

cdgriffith added a commit that referenced this issue Aug 26, 2023
* Adding #255 defer ipython import for large import speed improvements (thanks to Eric Prestat)
* Adding testing for Python 3.12
* Fixing #253 merge_update box list merge types not populated to sub dictionaries (thanks to lei wang)
* Fixing #257 Two test failures due to arguments having incorrect types (thanks to Michał Górny)
* Fixing stub files to match latest code signatures
* Removing #251 support for circular references in lists (thanks to d00m514y3r)

---------

Co-authored-by: Eric Prestat <eric.prestat@gmail.com>
@cdgriffith
Copy link
Owner

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!

@mgorny
Copy link
Contributor Author

mgorny commented Aug 27, 2023

Thanks, it looks good now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants