diff --git a/.github/workflows/bindings-python.yml b/.github/workflows/bindings-python.yml index 1215af362f..370979fdcf 100644 --- a/.github/workflows/bindings-python.yml +++ b/.github/workflows/bindings-python.yml @@ -117,6 +117,11 @@ jobs: working-directory: bindings/python run: tox -e lint-examples + - name: Run linter for tests + if: ${{ startsWith(matrix.os, 'ubuntu-latest') }} + working-directory: bindings/python + run: tox -e lint-tests + - name: Run tests working-directory: bindings/python run: tox diff --git a/bindings/python/examples/.pylintrc b/bindings/python/.pylintrc similarity index 100% rename from bindings/python/examples/.pylintrc rename to bindings/python/.pylintrc diff --git a/bindings/python/tests/address_generation_test.py b/bindings/python/tests/address_generation_test.py index d7037dc94e..b4a87e9d7a 100644 --- a/bindings/python/tests/address_generation_test.py +++ b/bindings/python/tests/address_generation_test.py @@ -2,8 +2,8 @@ # Copyright 2023 IOTA Stiftung # SPDX-License-Identifier: Apache-2.0 -from iota_sdk import Wallet, MnemonicSecretManager, CoinType, ClientOptions import shutil +from iota_sdk import Wallet, MnemonicSecretManager, CoinType, ClientOptions def test_address_generation_iota(): diff --git a/bindings/python/tests/test_offline.py b/bindings/python/tests/test_offline.py index 0e7b2601ab..4ae046a7ab 100644 --- a/bindings/python/tests/test_offline.py +++ b/bindings/python/tests/test_offline.py @@ -2,13 +2,14 @@ # Copyright 2023 IOTA Stiftung # SPDX-License-Identifier: Apache-2.0 -from iota_sdk import Block, Client, MnemonicSecretManager, Utils, SecretManager, OutputId, hex_to_utf8, utf8_to_hex, Bip44, CoinType, Irc27Metadata, Irc30Metadata import json import unittest +from iota_sdk import Block, Client, MnemonicSecretManager, Utils, SecretManager, OutputId, hex_to_utf8, utf8_to_hex, Bip44, CoinType, Irc27Metadata, Irc30Metadata + # Read the test vector -tv = dict() -with open('../../sdk/tests/client/fixtures/test_vectors.json') as json_file: +tv = {} +with open('../../sdk/tests/client/fixtures/test_vectors.json', "r", encoding="utf-8") as json_file: tv = json.load(json_file) client = Client() @@ -57,13 +58,11 @@ def test_output_id(self): transaction_id = '0x52fdfc072182654f163f5f0f9a621d729566c74d10037c4d7bbb0407d1e2c649' output_index = 42 output_id = OutputId(transaction_id, output_index) - assert output_id.__repr__( - ) == '0x52fdfc072182654f163f5f0f9a621d729566c74d10037c4d7bbb0407d1e2c6492a00' + assert repr(output_id) == '0x52fdfc072182654f163f5f0f9a621d729566c74d10037c4d7bbb0407d1e2c6492a00' new_output_id = OutputId.from_string( '0x52fdfc072182654f163f5f0f9a621d729566c74d10037c4d7bbb0407d1e2c6492a00') - assert new_output_id.__repr__( - ) == '0x52fdfc072182654f163f5f0f9a621d729566c74d10037c4d7bbb0407d1e2c6492a00' + assert repr(new_output_id) == '0x52fdfc072182654f163f5f0f9a621d729566c74d10037c4d7bbb0407d1e2c6492a00' assert new_output_id.transaction_id == transaction_id assert new_output_id.output_index == output_index diff --git a/bindings/python/tests/test_output.py b/bindings/python/tests/test_output.py index 201d4059a2..daa3b97d1f 100644 --- a/bindings/python/tests/test_output.py +++ b/bindings/python/tests/test_output.py @@ -2,8 +2,8 @@ # Copyright 2023 IOTA Stiftung # SPDX-License-Identifier: Apache-2.0 -from iota_sdk import BasicOutput, AliasOutput, FoundryOutput, NftOutput, IssuerFeature, MetadataFeature from dacite import from_dict +from iota_sdk import BasicOutput, AliasOutput, FoundryOutput, NftOutput, IssuerFeature, MetadataFeature def test_feature(): diff --git a/bindings/python/tests/test_wallet_destroy.py b/bindings/python/tests/test_wallet_destroy.py index 132b491602..f3e11fe70d 100644 --- a/bindings/python/tests/test_wallet_destroy.py +++ b/bindings/python/tests/test_wallet_destroy.py @@ -1,9 +1,9 @@ # Copyright 2023 IOTA Stiftung # SPDX-License-Identifier: Apache-2.0 -from iota_sdk import Wallet, MnemonicSecretManager, CoinType, ClientOptions, WalletError import shutil import unittest +from iota_sdk import Wallet, MnemonicSecretManager, CoinType, ClientOptions, WalletError class WalletDestroy(unittest.TestCase): diff --git a/bindings/python/tox.ini b/bindings/python/tox.ini index b8a8c96a45..d436391bfe 100644 --- a/bindings/python/tox.ini +++ b/bindings/python/tox.ini @@ -30,4 +30,13 @@ deps = pylint commands = pip install . - pylint --rcfile=examples/.pylintrc examples/**/*.py + pylint --rcfile=.pylintrc examples/**/*.py + +[testenv:lint-tests] +description = Run pylint {basepython} on tests +deps = + -r requirements-dev.txt + pylint +commands = + pip install . + pylint --disable=missing-function-docstring,missing-class-docstring --rcfile=.pylintrc tests/**/*.py