I don't understand why my pytest of the following function is not passing:
solutions/_and.py
def _and(a, b):
if a:
return b
return False
test_and.py
_and_path='./solutions/'
import itertools
import sys
sys.path.append(_and_path)
print(sys.path)
import _and
def test_and():
for i, j in itertools.product([True, False], [True, False]):
assert(_and._and(i, j) == i and j)
The failure report:
pytest
================================================= test session starts =================================================
platform win32 -- Python 3.6.4, pytest-5.2.4, py-1.8.0, pluggy-0.13.0
rootdir: C:\Users\Joseph\projects\byoc
collected 2 items
test_and.py .F [100%]
====================================================== FAILURES =======================================================
______________________________________________________ test_and _______________________________________________________
def test_and():
for i, j in itertools.product([True, False], [True, False]):
> assert(_and._and(i, j) == i and j)
E assert (False == True)
E + where False = <function _and at 0x000001F2A5ED7BF8>(True, False)
E + where <function _and at 0x000001F2A5ED7BF8> = _and._and
test_and.py:14: AssertionError
============================================= 1 failed, 1 passed in 0.08s =============================================
I'm new to Pytest, but it seems to me that my version of and
is returning False
when (True, False)
are its parameters, but i and j
from the test is returning True
with those same parameters. Am I missing something?
Aucun commentaire:
Enregistrer un commentaire