Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:

At a quick glance, I am 95% sure the problem lies in these two snippets of your 
code, not unittest:

    class My_Time:
        months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]


    if is_leapyr(year):
        my_time.months[1] = 29


The first snippet makes months, a mutable list, a class attribute, which means 
it is shared by all instances of the class. The second snippet mutates that 
list, which means every single instance will see the same value.

So commenting out some tests will change whether or not the shared list gets 
mutated, which will change whether or not other tests pass or fail.

I think the smallest change you need make to fix your code is to put the 
initialisation of My_Time into an `__init__` method, so that the attributes 
(including the list) are no longer shared between all instances.

    class My_Time:
        def __init__(self):
            ...

----------
nosy: +steven.daprano

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45827>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to