samedi 30 mai 2020

How to correctly import and test a class into a pytest python file?

I am trying to learn about python testing with pytest.
i have built a class named YBlizer but when I try to import it to my test file and test its function pytest tells me its value is None. here is what I mean:

class:

class YBlizer():

    @staticmethod
    def display_menu():
        print("""Welcome to YOUTUBELIZER
=======================""")

test:

import pytest
from Yout.Youtubeilizer import YBlizer


def test_two(youb):
    test = youb.display_menu()
    assert test is not None


@pytest.fixture
def youb():
    return YBlizer()

after that i run: pytest tests\test_Youtubeilizer.py

and i get the following message:

FAILED tests/test_Youtubeilizer.py::test_two - assert None is not None

can someone please explain to me why the display_menu method is considered None in my test file and how can i fix this?

thanks!

Aucun commentaire:

Enregistrer un commentaire