# Teste unitário com pytest

**URL:** <https://forum.casadocodigo.com.br/t/teste-unitario-com-pytest/1956>\
**Category:** Livros\
**Created:** [Novembro 25, 2021, 1:18am UTC](https://forum.casadocodigo.com.br/t/teste-unitario-com-pytest/1956 "2021-11-25T01:18:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arysthon](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arysthon](https://forum.casadocodigo.com.br/u/Arysthon)\
**Post date:** [Novembro 25, 2021, 1:18am UTC](https://forum.casadocodigo.com.br/t/teste-unitario-com-pytest/1956/1 "2021-11-25T01:18:58Z")

</div>

Olá, comecei a estudar e fazer alguns testes usando o pytest, porém não está indo. Eu tbm não possuo tanto conhecimento assim em python, então não sei se errei algo básico na linguagem que não roda o teste. Se alguém puder ajudar serei muito grato.

def check\_eligible\_state(state :str) → float:

```
''' It checks if one state is eligible to some random policies.

    Args:

        state (string): The State in Brazil

    Returns:

        variable (bool): Whether the state is eligible

'''

     

policy_1 = state in ['AC', 'AL', 'AP', 'AM', 'BA', 'CE', 'DF', 'ES', 'GO', 'MA', 'MT', 'MS']        

policy_2 = state in ['MG', 'PA', 'PB', 'PR', 'PE', 'PI', 'RJ', 'RN', 'RS', 'RO', 'RR', 'SC', 'SP', 'SE', 'TO']

policy_3 = state in ['ES', 'MG', 'RJ', 'SP']

if (policy_1 or policy_2) and policy_3:

    return True

else:

    return False

```

check\_eligible\_state = [(“AC”, “AL”, “ES”),

```
                 ("GO", "MS", "RJ"),

                 ("SE", "PI", "MG")]

```

@pytest.mark.parametrize([“state”], check\_eligible\_state)

def test\_check\_eligible\_state(state, ):

```
   assert misc.check_eligible_state(state) == True
```
