-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cecc6d8
commit f55402e
Showing
4 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from functools import singledispatchmethod | ||
from typing import Any | ||
import unittest | ||
|
||
import pure_interface | ||
|
||
|
||
class TestSingleDispatch(unittest.TestCase): | ||
def test_single_dispatch_allowed(self): | ||
class IPerson(pure_interface.Interface): | ||
@singledispatchmethod | ||
def greet(self, other_person: Any) -> str: | ||
pass | ||
|
||
self.assertSetEqual(pure_interface.get_interface_method_names(IPerson), {'greet'}) | ||
|
||
def test_single_dispatch_checked(self): | ||
class IPerson(pure_interface.Interface): | ||
def greet(self) -> str: | ||
pass | ||
|
||
pure_interface.set_is_development(True) | ||
with self.assertRaises(pure_interface.InterfaceError): | ||
class Person(IPerson): | ||
@singledispatchmethod | ||
def greet(self, other_person: Any) -> str: | ||
pass | ||
|