laike9m / pdir2

Pretty dir() printing with joy:beer:
MIT License
1.33k stars 47 forks source link

test suite fails in Python 3.7 #39

Closed carlwgeorge closed 6 years ago

carlwgeorge commented 6 years ago

The test suite fails when run under Python 3.7.0b5.

root@54cdf970be00:/pdir2-0.3.0# PYTHONPATH=$PWD py.test -svv tests
========================================================= test session starts ==========================================================
platform linux -- Python 3.7.0b5, pytest-3.6.2, py-1.5.3, pluggy-0.6.0 -- /usr/local/bin/python
cachedir: .pytest_cache
rootdir: /pdir2-0.3.0, inifile:
collected 30 items                                                                                                                     

tests/test_attr.py::test_attrtype_equality PASSED
tests/test_attr.py::test_attrtype_compare PASSED
tests/test_buggy_attrs.py::test_dataframe PASSED
tests/test_buggy_attrs.py::test_type PASSED
tests/test_buggy_attrs.py::test_list PASSED
tests/test_buggy_attrs.py::test_descriptor PASSED
tests/test_container.py::test_acting_like_a_list PASSED
tests/test_container.py::test_acting_like_a_list_when_search PASSED
tests/test_container.py::test_attr_order PASSED
tests/test_filters.py::test_properties PASSED
tests/test_filters.py::test_methods PASSED
tests/test_filters.py::test_public PASSED
tests/test_filters.py::test_own PASSED
tests/test_filters.py::test_chained_filters PASSED
tests/test_filters.py::test_order_of_chained_filters PASSED
tests/test_filters.py::test_filters_with_search PASSED
tests/test_pdir_format.py::test_pdir_module module attribute:
    __cached__, __file__, __loader__, __name__, __package__, __spec__
property:
    __builtins__, a, b
special attribute:
    __doc__
class:
    OOO: OOO today.
function:
    func: This is a function
PASSED
tests/test_pdir_format.py::test_pdir_object abstract class:
    __subclasshook__
attribute access:
    __delattr__, __dir__, __getattribute__, __setattr__
class customization:
    __init_subclass__
object customization:
    __format__, __hash__, __init__, __new__, __repr__, __sizeof__, __str__
pickle:
    __reduce__, __reduce_ex__
rich comparison:
    __eq__, __ge__, __gt__, __le__, __lt__, __ne__
special attribute:
    __class__, __dict__, __doc__, __module__, __weakref__
function:
    what: doc line
PASSED
tests/test_pdir_format.py::test_pdir_class FAILED
tests/test_pdir_format.py::test_dir_without_argument property:
    a, b
function:
    whatever: One line doc.
PASSED
tests/test_search.py::test_search_without_argument PASSED
tests/test_search.py::test_search_with_argument PASSED
tests/test_z_config.py::test_default_env_without_config PASSED
tests/test_z_config.py::test_set_env_without_config PASSED
tests/test_z_config.py::test_read_config PASSED
tests/test_z_config.py::test_read_config_from_custom_location PASSED
tests/test_z_config.py::test_uniform_color PASSED
tests/test_z_config.py::test_empty_config PASSED
tests/test_z_config.py::test_invalid_config_1 PASSED
tests/test_z_config.py::test_invalid_config_2 PASSED

=============================================================== FAILURES ===============================================================
___________________________________________________________ test_pdir_class ____________________________________________________________

    def test_pdir_class():
        class T(object):
            pass

        result = pdir(T)
        if sys.version[0] == '2':
            assert result.repr_str == repr(result) == '\n'.join([
                '\x1b[0;33mabstract class:\x1b[0m',
                '    \x1b[0;36m__subclasshook__\x1b[0m',
                '\x1b[0;33mattribute access:\x1b[0m',
                ('    \x1b[0;36m__delattr__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__getattribute__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__setattr__\x1b[0m'
                 ), '\x1b[0;33mobject customization:\x1b[0m',
                ('    \x1b[0;36m__format__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__hash__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__init__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__new__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__repr__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__sizeof__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__str__\x1b[0m'), '\x1b[0;33mpickle:\x1b[0m',
                ('    \x1b[0;36m__reduce__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__reduce_ex__\x1b[0m'
                 ), '\x1b[0;33mspecial attribute:\x1b[0m',
                ('    \x1b[0;36m__class__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__dict__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__doc__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__module__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__weakref__\x1b[0m')
            ])
        elif sys.version_info[:2] == (3, 6):
            assert result.repr_str == repr(result) == '\n'.join([
                '\x1b[0;33mabstract class:\x1b[0m',
                '    \x1b[0;36m__subclasshook__\x1b[0m',
                '\x1b[0;33mattribute access:\x1b[0m',
                ('    \x1b[0;36m__delattr__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__dir__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__getattribute__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__setattr__\x1b[0m'
                 ), '\x1b[0;33mclass customization:\x1b[0m',
                '    \x1b[0;36m__init_subclass__\x1b[0m',
                '\x1b[0;33mobject customization:\x1b[0m',
                ('    \x1b[0;36m__format__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__hash__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__init__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__new__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__repr__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__sizeof__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__str__\x1b[0m'), '\x1b[0;33mpickle:\x1b[0m',
                ('    \x1b[0;36m__reduce__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__reduce_ex__\x1b[0m'
                 ), '\x1b[0;33mrich comparison:\x1b[0m',
                ('    \x1b[0;36m__eq__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__ge__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__gt__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__le__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__lt__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__ne__\x1b[0m'
                 ), '\x1b[0;33mspecial attribute:\x1b[0m',
                ('    \x1b[0;36m__class__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__dict__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__doc__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__module__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__weakref__\x1b[0m')
            ])
        else:
>           assert result.repr_str == repr(result) == '\n'.join([
                '\x1b[0;33mabstract class:\x1b[0m',
                '    \x1b[0;36m__subclasshook__\x1b[0m',
                '\x1b[0;33mattribute access:\x1b[0m',
                ('    \x1b[0;36m__delattr__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__dir__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__getattribute__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__setattr__\x1b[0m'
                 ), '\x1b[0;33mobject customization:\x1b[0m',
                ('    \x1b[0;36m__format__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__hash__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__init__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__new__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__repr__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__sizeof__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__str__\x1b[0m'), '\x1b[0;33mpickle:\x1b[0m',
                ('    \x1b[0;36m__reduce__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__reduce_ex__\x1b[0m'
                 ), '\x1b[0;33mrich comparison:\x1b[0m',
                ('    \x1b[0;36m__eq__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__ge__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__gt__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__le__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__lt__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__ne__\x1b[0m'
                 ), '\x1b[0;33mspecial attribute:\x1b[0m',
                ('    \x1b[0;36m__class__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__dict__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__doc__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__module__\x1b[0m\x1b[1;30m, '
                 '\x1b[0m\x1b[0;36m__weakref__\x1b[0m')
            ])
E           AssertionError: assert '\x1b[0;33mab...kref__\x1b[0m' == '\x1b[0;33mabs...kref__\x1b[0m'
E               abstract class:
E                   __subclasshook__
E               attribute access:
E                   __delattr__, __dir__, __getattribute__, __setattr__
E             - class customization:
E             -     __init_subclass__
E               object customization:
E                   __format__, __hash__, __init__, __new__, __repr__, __sizeof__, __str__
E               pickle:
E                   __reduce__, __reduce_ex__
E               rich comparison:
E                   __eq__, __ge__, __gt__, __le__, __lt__, __ne__
E               special attribute:
E                   __class__, __dict__, __doc__, __module__, __weakref__

tests/test_pdir_format.py:123: AssertionError
================================================= 1 failed, 29 passed in 0.57 seconds ==================================================
laike9m commented 6 years ago

Sorry, these tests only work well with Python 2.7 and 3.6, because calling dir in different versions of Python will give you different result. It's a bit annoying but I don't see how it can be avoided.

laike9m commented 6 years ago

Well, actually there is solution, like adding golden data for different versions. I didn't do it cause I felt it's not worth the effort.

carlwgeorge commented 6 years ago

FYI Python 3.7 is expected to be released this week.

laike9m commented 6 years ago

I know that. Let me know if you have any good suggestion.

carlwgeorge commented 6 years ago

Would you be open to a pull request to mark it as expected to fail?

laike9m commented 6 years ago

Sounds good, I'll accept it.