Skip to content

Conversation

@Ziaad-Khaled
Copy link

Testing Python Code Report

Description

This exercise involved adding assertion statements, writing unit and integration tests, and ensuring code coverage for a 2D diffusion equation solver (diffusion2d.py). The process included verifying the tests by intentionally introducing bugs and setting up automation using tox.

Notes

  • Assertions: Added parameter checks. Identified that default temperature values were integers (300, 700), causing AssertionError: T_cold should be a float. Fixed by changing to floats (300., 700.).
  • Unit Test Verification:
    • Intentionally introduced a bug in initialize_domain (self.nx = int(h / dx)).
    • Test test_initialize_domain correctly failed (AssertionError: 20 != 40).
    • Refactored tests to unittest and verified the bug was still caught.
  • Integration Test Verification:
    • Intentionally introduced a bug in initialize_physical_parameters (used * instead of + in denominator).
    • Integration test test_initialize_physical_parameters correctly failed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant