Skip to content

Commit c74e2bd

Browse files
committed
fix flake8 errors
1 parent 16a8da8 commit c74e2bd

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
author_email='contact@pyth.network',
1111
install_requires=requirements,
1212
extras_require={
13-
'testing': requirements + ['mock', 'pytest', 'pytest-cov', 'pytest-socket', 'pytest-mock', 'pytest-asyncio'],
13+
'testing': requirements + ['mock', 'pytest', 'pytest-cov', 'pytest-socket',
14+
'pytest-mock', 'pytest-asyncio'],
1415
},
1516
python_requires='>=3.7.0',
1617
)

tests/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ def solana_client():
1212
ws_endpoint="wss://example.com",
1313
)
1414

15+
1516
@pytest.fixture
1617
def caplog(_caplog):
18+
logger.enable("pythclient")
19+
1720
class PropogateHandler(logging.Handler):
1821
def emit(self, record):
1922
logging.getLogger(record.name).handle(record)
2023

2124
handler_id = logger.add(PropogateHandler(), format="{message}")
2225
yield _caplog
23-
logger.remove(handler_id)
26+
logger.remove(handler_id)

tests/test_solana_account.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from mock import AsyncMock
44

55

6-
from pythclient.solana import SolanaAccount, SolanaPublicKey, SolanaClient
6+
from pythclient.solana import SolanaAccount, SolanaPublicKey
77

88

99
@pytest.fixture
@@ -18,6 +18,7 @@ def solana_account(solana_pubkey, solana_client):
1818
solana=solana_client,
1919
)
2020

21+
2122
@pytest.fixture()
2223
def mock_get_account_info(mocker):
2324
async_mock = AsyncMock()
@@ -32,8 +33,8 @@ def test_solana_account_update_with_rpc_response(
3233
key=solana_pubkey,
3334
solana=solana_client,
3435
)
35-
assert actual.slot == None
36-
assert actual.lamports == None
36+
assert actual.slot is None
37+
assert actual.lamports is None
3738

3839
slot = 106498726
3940
value = {
@@ -45,6 +46,7 @@ def test_solana_account_update_with_rpc_response(
4546
assert actual.slot == slot
4647
assert actual.lamports == value["lamports"]
4748

49+
4850
@pytest.mark.asyncio
4951
async def test_solana_account_update_success(mock_get_account_info, solana_pubkey, solana_client):
5052
actual = SolanaAccount(
@@ -54,11 +56,11 @@ async def test_solana_account_update_success(mock_get_account_info, solana_pubke
5456

5557
mock_get_account_info.return_value = {'context': {'slot': 93752509}, 'value': {'lamports': 1000000001}}
5658

57-
5859
await actual.update()
5960
assert actual.slot == mock_get_account_info.return_value['context']['slot']
6061
assert actual.lamports == mock_get_account_info.return_value['value']['lamports']
6162

63+
6264
@pytest.mark.asyncio
6365
async def test_solana_account_update_fail(mock_get_account_info, caplog, solana_pubkey, solana_client):
6466
actual = SolanaAccount(
@@ -70,19 +72,20 @@ async def test_solana_account_update_fail(mock_get_account_info, caplog, solana_
7072
await actual.update()
7173
assert exc_message in caplog.text
7274

75+
7376
@pytest.mark.asyncio
7477
async def test_solana_account_update_null(mock_get_account_info, caplog, solana_pubkey, solana_client):
7578
actual = SolanaAccount(
7679
key=solana_pubkey,
7780
solana=solana_client,
7881
)
7982
mock_get_account_info.return_value = {'context': {'slot': 93752509}}
80-
exc_message = f'got null value from Solana getAccountInfo for {solana_pubkey}; non-existent account? {mock_get_account_info.return_value}'
83+
exc_message = f'got null value from Solana getAccountInfo for {solana_pubkey}; ' \
84+
+ f'non-existent account? {mock_get_account_info.return_value}'
8185
await actual.update()
8286
assert exc_message in caplog.text
8387

8488

85-
8689
def test_solana_account_str(solana_account):
8790
actual = str(solana_account)
8891
expected = f"SolanaAccount ({solana_account.key})"

0 commit comments

Comments
 (0)