Skip to content

Migrate all Integration Tests to Pytest and Refactor Test Framework#794

Draft
moisesPompilio wants to merge 25 commits intogetfloresta:masterfrom
moisesPompilio:convert-all-test-pytest
Draft

Migrate all Integration Tests to Pytest and Refactor Test Framework#794
moisesPompilio wants to merge 25 commits intogetfloresta:masterfrom
moisesPompilio:convert-all-test-pytest

Conversation

@moisesPompilio
Copy link
Collaborator

@moisesPompilio moisesPompilio commented Jan 19, 2026

Description and Notes

This PR migrates all existing integration tests to use the pytest framework, removing the old custom test_runner which is no longer necessary. The FlorestaTestFramework has been significantly refactored to align with pytest conventions; custom assertion methods and main entry points have been removed since pytest handles these natively.

Key improvements include:

  • Pytest migration: All tests now follow pytest standards and conventions.
  • Logging infrastructure: The RPC, daemon, and electrum classes now use proper logging instead of print statements, improving debuggability and test output clarity.
  • Helper function connect: A new helper function has been introduced to automatically connect all nodes to each other in tests, simplifying test code by eliminating repetitive peer connection setup.
  • Framework simplification: Removed unnecessary assertion implementations and main methods from FlorestaTestFramework.

Note: This PR depends on PR #742 and should be merged after it.
Close: #783

How to verify the changes you have done?

  • Run the integration tests using the traditional command:
    ./tests/run.sh
  • Confirm that pytest is now being used to execute the tests.
  • Verify that all tests pass successfully under the pytest framework.
  • Check the test output to ensure proper logging is used (not print statements) for RPC, daemon, and electrum classes.
  • Review test code to confirm the connect helper function simplifies node connection setup and reduces boilerplate code.

@moisesPompilio
Copy link
Collaborator Author

moisesPompilio commented Jan 19, 2026

This PR is not completely ready because some points in the get_txout test still need to be fixed, and the commit messages need improvement. However, you can already get a preview of how the tests look with pytest and how much faster test execution is now.

cc: @joaozinhom

@Davidson-Souza Davidson-Souza added code quality Generally improves code readability and maintainability Integration Issues related to our integration tests labels Jan 19, 2026
moisesPompilio and others added 25 commits January 19, 2026 20:03
Introduce pytest as the new testing framework to simplify and enhance the way
tests are written and executed. Pytest facilitates the creation of reusable
functions and fixtures, making it easier to manage and instantiate nodes
dynamically. It also provides built-in assertion functions and a robust
test runner.

co-authored-by: joaozinhom <joaozinhom@users.noreply.github.com>
Introduce multithread support for pytest in the functional tests, enabling tests
to run in parallel with a default of 4 workers.

To ensure proper isolation and avoid conflicts between tests running simultaneously,
the `/data` directory for nodes is now generated dynamically based on the name of
the test being executed. This adjustment leverages the `request.node.name` attribute
to create unique data directories for each test.

co-authored-by: joaozinhom <joaozinhom@users.noreply.github.com>
…unner.py

Migrated the Electrum example test to use pytest, simplifying the test structure.
Removed the requirement for all tests to be listed in test_runner.py, allowing
tests to be run independently with pytest.

co-authored-by: joaozinhom <joaozinhom@users.noreply.github.com>
…work

- Merged the addnode_v1 and addnode_v2 tests into
a single pytest file `addnode.py`.
- Introduced the `TestAddNode` class to encapsulate
the tests.
- Added `test_add_node_v1` and `test_add_node_v2`
methods to handle v1 and v2 transport protocol
tests, respectively.
…hain test to pytest

- Added the `florestad_utreexod` fixture to simplify tests requiring both a
  `florestad` and `utreexod` node. The fixture automatically creates, starts,
  and connects the nodes, making them ready for testing.
- Migrated the `reorg_chain` test to pytest, utilizing the new
  `florestad_utreexod` fixture for node setup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code quality Generally improves code readability and maintainability Integration Issues related to our integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants