forked from TrueCloudLab/frostfs-testlib
Add repr and str for most classes used in parametrize
Signed-off-by: Andrey Berezin <a.berezin@yadro.com>
This commit is contained in:
parent
38742badf2
commit
2240be09d2
14 changed files with 187 additions and 48 deletions
27
src/frostfs_testlib/testing/readable.py
Normal file
27
src/frostfs_testlib/testing/readable.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from abc import ABCMeta
|
||||
|
||||
|
||||
class HumanReadableABCMeta(ABCMeta):
|
||||
def __str__(cls):
|
||||
if "__repr_name__" in cls.__dict__:
|
||||
return cls.__dict__["__repr_name__"]
|
||||
return cls.__name__
|
||||
|
||||
def __repr__(cls):
|
||||
if "__repr_name__" in cls.__dict__:
|
||||
return cls.__dict__["__repr_name__"]
|
||||
return cls.__name__
|
||||
|
||||
|
||||
class HumanReadableABC(metaclass=HumanReadableABCMeta):
|
||||
@classmethod
|
||||
def __str__(cls):
|
||||
if "__repr_name__" in cls.__dict__:
|
||||
return cls.__dict__["__repr_name__"]
|
||||
return type(cls).__name__
|
||||
|
||||
@classmethod
|
||||
def __repr__(cls):
|
||||
if "__repr_name__" in cls.__dict__:
|
||||
return cls.__dict__["__repr_name__"]
|
||||
return type(cls).__name__
|
Loading…
Add table
Add a link
Reference in a new issue