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

zope.schema.Bool violates it's interface spec #113

Open
agroszer opened this issue Dec 13, 2021 · 0 comments
Open

zope.schema.Bool violates it's interface spec #113

agroszer opened this issue Dec 13, 2021 · 0 comments

Comments

@agroszer
Copy link
Contributor

Still regressions on the Bool default thing....

    def test_field_Bool_is_required(self):
        # the Bool field is required by default
        from zope.schema import Bool
        field = Bool(__name__='testing')
        self.assertTrue(field.required)

    def test_field_Bool_default_is_None(self):
        # the Bool field has no default set (None)
        from zope.schema import Bool
        field = Bool(__name__='testing')
        self.assertIsNone(field.default)


    def test_bool_not_required(self):
        """If class Bool is used as a schema itself, it must not be required.
        """
        from zope.schema.interfaces import IBool
        # treat IBool as schema with fields
        field = IBool.get("required")
        self.assertFalse(field.required)

    def test_bool_defaults_to_false(self):
        """If class Bool is used as a schema itself, it must default to False
        """
        from zope.schema.interfaces import IBool
        # treat IBool as schema with fields
        field = IBool.get("default")
        self.assertFalse(field.default)

since

classImplementsFirst(Bool, IBool)

I'd expect that IBool['default'] == Bool().default and IBool['required'] == Bool().required otherwise Bool violates it's interface contract.

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

1 participant