Skip to content

Refactor integration tests to use the shared env pytest fixture instead of manual IntegrationTestEnv()Β #2789

Closed

Description

@manishdait

πŸ†•πŸ₯ Newcomer Friendly

Welcome! This is a Good First Issue designed to be approachable to brand-new contributors.

🏁 When this issue is complete, you will have:

βœ… Learned how to fork and navigate the codebase
βœ… Learned our contribution workflow
βœ… Implemented a real change to the SDK

🐞 Problem Description

Many integration tests create their own test environment by hand:

env = IntegrationTestEnv()
try:
    ...
finally:
    env.close()

Other tests already receive the environment through a pytest fixture, for example test_integration_file_contents_query_insufficient_payment(env).

πŸ’‘ Solution

Change the affected tests to take the env fixture as a function argument. The fixture creates the environment and closes it after the test. This removes the manual IntegrationTestEnv() call and the try/finally block, and the test logic stays the same.

πŸ› οΈ Implementation Steps

Files to change

  • tests/integration/account_balance_query_e2e_test.py
  • tests/integration/token_airdrop_transaction_cancel_e2e_test.py
  • tests/integration/token_airdrop_transaction_e2e_test.py
  • tests/integration/token_associate_transaction_e2e_test.py
  • tests/integration/token_burn_transaction_e2e_test.py
  • tests/integration/token_create_with_custom_fee_e2e_test.py
  • tests/integration/token_delete_transaction_e2e_test.py
  • tests/integration/token_fee_schedule_update_transaction_e2e_test.py
  • tests/integration/token_freeze_transaction_e2e_test.py
  • tests/integration/token_grant_kyc_transaction_e2e_test.py
  • tests/integration/token_info_query_e2e_test.py
  • tests/integration/token_mint_transaction_e2e_test.py
  • tests/integration/token_nft_info_query_e2e_test.py
  • tests/integration/token_reject_transaction_e2e_test.py
  • tests/integration/token_revoke_kyc_transaction_e2e_test.py
  • tests/integration/token_unfreeze_transaction_e2e_test.py
  • tests/integration/token_update_nfts_transaction_e2e_test.py
  • tests/integration/token_update_transaction_e2e_test.py
  • tests/integration/token_wipe_account_transaction_e2e_test.py
  • tests/integration/topic_create_transaction_e2e_test.py
  • tests/integration/topic_delete_transaction_e2e_test.py
  • tests/integration/topic_info_query_e2e_test.py
  • tests/integration/topic_update_transaction_e2e_test.py

Proposed Solution:

  • Look at how an existing test uses the fixture, for example test_integration_file_contents_query_insufficient_payment in tests/integration/file_contents_query_e2e_test.py, and at the env fixture in conftest.py.
  • In each file, find tests that contain env = IntegrationTestEnv().
  • Add env as a parameter to the test function signature.
  • Delete the env = IntegrationTestEnv() line.
  • Remove the try: / finally: env.close() wrapper and de-indent the body by one level.
  • Remove the IntegrationTestEnv import if it is no longer used in the file.
# Example snippet
@pytest.mark.integration
def test_integration_token_cancel_airdrop_transaction_can_execute():
    env = IntegrationTestEnv()
    try:
       ...
    finally:
        env.close()

# After change
@pytest.mark.integration
def test_integration_token_cancel_airdrop_transaction_can_execute(env):
  ...
  • Do not change the test logic or assertions. Helper functions that take env as an argument keep working as they are.
  • Run the e2e tests

🧠 Good First Issue Developers β€” Prerequisites & Expectations

Important

This issue does not require prior domain knowledge.

  • No Hiero or Hedera experience needed
  • No distributed ledger background required
  • Beginner Programming is sufficient

Note

⏱️ Typical time to complete: ~1 Day / ~4 hours (including set-up)
🧩 Difficulty: Small, well-contained change
πŸŽ“ Best for: New contributors

πŸ€– AI Usage Policy

  • Good First Issues are open for humans, AI bot-authored PRs will be rejected.
  • Refer to our set-up and workflow guides, AI may make mistakes.

Warning

We expect pull requests to use our workflow and meet the quality standards outlined in this issue.

πŸ“‹ Step-by-Step Setup Procedure

  • Visual Studio (VS) Code: Guide

  • GitHub Desktop: Guide

  • Hedera Testnet Account with root .env file: Guide

  • Create a GPG key linked to GitHub: Guide

  • Fork Create an online and local copy of the repository: Guide

  • Connect origin with upstream: Guide

  • Install Packages and protobufs: Guide

  • Windows users: see the Windows Setup Guide for platform-specific installation steps.

  • Sync Main pull any recent upstream changes: Guide

  • Pre-commit Hooks: Setup pre-commit hooks for linting and formatting: Guide

You are set up! πŸŽ‰

πŸ“‹ Step-by-step workflow guide

βœ… Get ready

  • Claim the issue: comment /assign: Guide. Pull requests created without being assigned will be automatically closed.

  • Double check the Issue and AI plan: carefully re-read the issue description and any AI plan below

  • Ask questions early: ask on Discord, and the @good_first_issue_support_team (setup and workflow help)

  • Sync Main pull any recent upstream changes: Guide

  • πŸ’‘ Tip: Before coding, you are free to leave a short comment describing what you plan to change. We'll confirm you're on the right track.

πŸ› οΈ Solve the Issue

  • Create a branch from main: Guide

  • Implement the solution: follow the implementation steps in the issue description.

  • Commit with Conventional format and DCO, GPG signing: commit changes using: git commit -S -s -m "chore: your message", Guide

πŸš€ Create the pull request

  • Push your commits: push your branch to your fork git push origin your-branch-name Guide

  • Open a pull request: Guide

  • Complete the PR description: briefly describe your changes, Guide

  • Link the Issue: link the issue the PR solves in the PR description, Guide. Pull requests created without a linked issue will be automatically closed.

  • Submit the pull request: click **Create pull request** and Ready to Review πŸŽ‰

βœ… PR Quality Checklist

To be able to close this issue, the following criteria must be met:

Workflow:

  • I have worked from a branch that is up to date with main
  • I have not made changes outside the scope of this issue
  • My commits are signed: git commit -S -s -m "chore: description" β€” Signing guide
  • I linked the issue in my PR description using Fixes #issue_number to automatically close it when merged
  • I have applied appropriate linting, code quality, and formatting tools used in this repo (if applicable).
  • I have installed and run pre-commit hooks to ensure code quality and formatting.

Issue Requirement:

  • The issue is solved: I've carefully read and implemented the issue requirements

πŸ€” What to expect after submitting a PR

Once you open a pull request, here's what happens next.

πŸ€– 1. Automated checks
Automated checks will run and all must pass before merging.
Open any failed check at the bottom of the PR to see details. Ask for help if you don't understand a failure or how to fix it.

😎 2. Initial Team review
Once tests pass, a team member will check if your PR follows the workflow.

βœ… 3. Team review
Once your tests pass and the workflow is followed, a team member will review the implementation.
You may be asked to make changes or your PR may be approved.
Approved PRs are usually merged within one day.

πŸ”„ Merge conflicts (sometimes)
Conflicts can happen and are normal as the SDK updates. Resolve using this Guide

Tip

Follow the workflow and double check your work
This is the best way to ensure a fast review and merge process.


🧭 Getting help if you're stuck

πŸ†˜ Stuck?

Tip

  • Comment on this issue and ask maintainers or tag @good_first_issue_support_team

Other Resources:


Activity

  1. added theissue type on Nov 13, 2026
  2. added
    Good First IssueIssues which are ideal for a first time or new project contributor.
    on Nov 13, 2026
  3. github-actions commented on Nov 13, 2026

    @github-actions

    Thanks for your submission.

    This issue is awaiting approval from @hiero-ledger/hiero-sdk-python-triage and @hiero-ledger/hiero-sdk-python-committers and @hiero-ledger/hiero-sdk-python-maintainers.

  4. locked as off topic and limited conversation to collaborators on Nov 13, 2026
  5. added
    approvedIssue has been approved by team member
    and removed on Nov 13, 2026
  6. unlocked this conversation on Nov 13, 2026
  7. github-actions commented on Nov 13, 2026

    @github-actions

    Approved by @hiero-ledger/hiero-sdk-python-triage and @hiero-ledger/hiero-sdk-python-committers and @hiero-ledger/hiero-sdk-python-maintainers.

  8. github-actions commented on Nov 13, 2026

    @github-actions
  9. Dhie-boop commented on Nov 14, 2026

    @Dhie-boop
    Contributor

    /assign

  10. github-actions commented on Nov 14, 2026

    @github-actions

    πŸ‘‹ Hi @Dhie-boop, you already have 1 open assignment (limit: 1). Please finish one before requesting another.

  11. AnanshSrivastava commented on Nov 15, 2026

    @AnanshSrivastava
    Contributor

    /assign

  12. AnanshSrivastava commented on Nov 15, 2026

    @AnanshSrivastava
    Contributor

    I’m starting on this. Plan: convert the 23 listed files to use the env fixture, one file at a time, and run each file’s tests against testnet before moving on.

  13. AnanshSrivastava commented on Nov 15, 2026

    @AnanshSrivastava
    Contributor

    Hi @good_first_issue_support_team, I'm working on this issue and have a question about running the integration tests locally.

    Setup: Windows, Python 3.14.6, uv, NETWORK=testnet with a Portal account (DER key).

    What I'm seeing: any test that runs CryptoGetAccountBalanceQuery fails with MaxAttemptsError (last error: precheck status BUSY (12)), while transactions succeed. For example, account_balance_query_e2e_test.py fails the same two tests (the other three pass) on clean main without my changes, and token_airdrop_transaction_e2e_test.py creates the account fine and then fails on the balance query. token_airdrop_transaction_cancel_e2e_test.py, which has no balance query, passes.

    Two questions: is this a known testnet issue for balance queries? And should I treat CI as the source of truth for these tests, and note in the PR which local tests hit BUSY?

    Thanks, and I'll keep going with the refactor in the meantime.

  14. Shayan1064 commented on Nov 15, 2026

    @Shayan1064

    /assign

  15. github-actions commented on Nov 15, 2026

    @github-actions

    πŸ‘‹ Hi @Shayan1064, thanks for your interest! This issue is already assigned to @AnanshSrivastava, but we'd love your help on another one. You can find more "Good First Issue" issues here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Good First IssueIssues which are ideal for a first time or new project contributor.approvedIssue has been approved by team member

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions