File: test_compat_with_abc_ABC.py

package info (click to toggle)
python-eth-utils 5.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,140 kB
  • sloc: python: 5,985; makefile: 238
file content (27 lines) | stat: -rw-r--r-- 629 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pytest
from abc import (
    ABCMeta,
    abstractmethod,
)
import logging

from eth_utils import (
    HasLoggerMeta,
)


class HasLoggerCompatWithABC(metaclass=HasLoggerMeta.meta_compat(ABCMeta)):
    @abstractmethod
    def something(self):
        ...


def test_has_logger_compat_with_abc_ABC():
    assert hasattr(HasLoggerCompatWithABC, "logger")
    assert isinstance(HasLoggerCompatWithABC.logger, logging.Logger)
    assert HasLoggerCompatWithABC.logger.name.endswith("HasLoggerCompatWithABC")


def test_abc_still_enforces_abstract_methods():
    with pytest.raises(TypeError):
        HasLoggerCompatWithABC()