-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes import of classes from implementations
- Loading branch information
Martin Matyasek
committed
May 15, 2019
1 parent
109c3a3
commit 03d9332
Showing
4 changed files
with
75 additions
and
39 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
Empty file.
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,38 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class A(ABC): | ||
@abstractmethod | ||
def test(self) -> None: | ||
pass | ||
|
||
@abstractmethod | ||
def test2(self) -> None: | ||
pass | ||
|
||
|
||
class B(A, ABC): # pylint: disable=W0223 | ||
def test(self) -> None: | ||
pass | ||
|
||
|
||
class C(B): | ||
def test2(self) -> None: | ||
pass | ||
|
||
|
||
class D(C): | ||
def test2(self) -> None: | ||
pass | ||
|
||
|
||
class E(A): | ||
def test(self) -> None: | ||
pass | ||
|
||
def test2(self) -> None: | ||
pass | ||
|
||
|
||
class F(E): | ||
__protected__ = True |
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,22 @@ | ||
from typing import List, Tuple, Type | ||
from unittest import TestCase | ||
|
||
from ftoolz.unsafe.reflection import implementations | ||
|
||
|
||
class ReflectionTest(TestCase): | ||
|
||
def test_implementations(self) -> None: | ||
from tests.test_unsafe.classes import A, B, E | ||
|
||
cases: List[Tuple[Type[A], List[str]]] = [ | ||
(A, ['C', 'D', 'E']), | ||
(B, ['C', 'D']), | ||
(E, []), | ||
] | ||
|
||
for clz, expected in cases: | ||
with self.subTest(clz=clz): | ||
impls = implementations(clz, __package__) | ||
actual = [c.__name__ for c in impls] | ||
self.assertListEqual(expected, actual) |