-
Notifications
You must be signed in to change notification settings - Fork 168
Expand file tree
/
Copy pathconftest.py
More file actions
60 lines (35 loc) · 830 Bytes
/
conftest.py
File metadata and controls
60 lines (35 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from time import sleep
import pytest
class Sessao:
contador = 0
usuarios = []
def salvar(self, usuario):
Sessao.contador += 1
usuario.id = Sessao.contador
self.usuarios.append(usuario)
def listar(self):
return self.usuarios
def roll_back(self):
self.usuarios.clear()
def fechar(self):
pass
class Conexao:
def __init__(self):
sleep(1)
def gerar_sessao(self):
return Sessao()
def fechar(self):
pass
@pytest.fixture(scope='session')
def conexao():
# Setup
conexao_obj = Conexao()
yield conexao_obj
# Tear Down
conexao_obj.fechar()
@pytest.fixture
def sessao(conexao):
sessao_obj = conexao.gerar_sessao()
yield sessao_obj
sessao_obj.roll_back()
sessao_obj.fechar()