Since one day I am faceing a rally strange error when running my pytests, they fail with either
E assert False is False
AssertionError
E assert True is True
AssertionError
But from my understanding and when checking it in python terminal that should give the correct output:
Python 3.6.9 (default, Oct 8 2020, 12:12:24)
>>> False is False
True
The outputs from pytest before running it
platform linux -- Python 3.6.8, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
plugins: cov-2.11.1, instafail-0.4.2, timeout-1.4.2
Does anyone have an idea what causes this behavior, because for me it makes no sense at all?
Important info
My question is not about the test itself it is about how can it happen, that pytest raises an explicit error telling me False is False is not True but False == False works without a problem?
This actually reproduces the issue:
from typing import Tuple
import numpy as np
import pytest
class MyObject():
def function_to_text(self, input: list) -> Tuple[bool, float]:
val = np.array(0) > 10
return val, 1.0
@pytest.fixture(scope='session')
def my_object():
my_obj = MyObject()
yield my_obj
def test_function_rejects_input(my_object):
assert my_object.function_to_text([])[0] is False
And by finding a way to reproduce this one now, I know now also what is the problem, see the answer for the solution