-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathconftest.py
More file actions
39 lines (33 loc) · 1.18 KB
/
conftest.py
File metadata and controls
39 lines (33 loc) · 1.18 KB
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
import pytest
import json
import os
from crypto.configuration.network import Network
from crypto.networks.testnet import Testnet
@pytest.fixture(scope='session', autouse=True)
def configure_network():
"""
Configures the network to Testnet before running any tests.
This fixture runs automatically once per test session.
"""
Network.set_network(Testnet())
@pytest.fixture
def load_transaction_fixture():
"""
Fixture to load a transaction fixture from the fixtures directory.
Usage in tests:
def test_example(load_transaction_fixture):
fixture = load_transaction_fixture('fixture_name')
"""
def _load_transaction_fixture(fixture_name):
fixtures_path = os.path.join(
os.path.dirname(__file__),
'./fixtures',
f'{fixture_name}.json'
)
with open(fixtures_path, 'r') as f:
return json.load(f)
return _load_transaction_fixture
@pytest.fixture
def passphrase():
"""Passphrase used for tests"""
return 'found lobster oblige describe ready addict body brave live vacuum display salute lizard combine gift resemble race senior quality reunion proud tell adjust angle'