Skip to content

Commit

Permalink
unit tests for provides()
Browse files Browse the repository at this point in the history
  • Loading branch information
glyph committed Aug 11, 2024
1 parent bfd2592 commit 923ed43
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/klein/test/test_attrs_zope.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from __future__ import annotations

import attrs
from zope.interface import Interface, implementer

from twisted.trial.unittest import SynchronousTestCase

from .._attrs_zope import provides


class IWhatever(Interface):
...


@implementer(IWhatever)
class YesWhatever:
...


class NoWhatever:
...


@attrs.define()
class WhateverContainer:
whatever: object = attrs.field(validator=provides(IWhatever))


class ProvidesTestCase(SynchronousTestCase):
def test_yes(self) -> None:
WhateverContainer(YesWhatever())

def test_no(self) -> None:
with self.assertRaises(TypeError):
WhateverContainer(NoWhatever())

0 comments on commit 923ed43

Please sign in to comment.