Skip to content

Refactor: Convert unittest to pytest in tests/unit_tests/test_helpers.py #497

Description

@blackboxsw

This task involves converting the tests within tests/unit_tests/test_cloud.py from unittest.TestCase-based tests to the pytest functional style.

Instructions for Copilot/Assignee:

  1. Remove TestCase Inheritance: Convert test classes inheriting from unittest.TestCase into regular Python classes or simply remove the classes and use standalone functions.
  2. Convert Assertions: Replace self.assertEqual(...), self.assertTrue(...), etc., with standard assert statements. pytest automatically handles assertion rewriting.
    3.Refactor Setup/Teardown:
  • Move setUp() methods to pytest.fixture functions.
  • Move tearDown() methods to finalizers in fixtures using yield or addfinalizer.
  1. Use mocker instead or mock.patch or mock.call
    5.Handle Exceptions: Replace self.assertRaises(...) with pytest.raises(...) as a context manager.

Acceptance criteria:

  • no remaining self.assert*, mock.call or mock.patch uses
  • no setUp or teadDown methods
  • If common mocks are used for most tests in a class, ensure the test class has a common setup_mocks fixture
  • Ensure proper format is applied by running tox -e format
  • Run Tests: Ensure all tests with tox -e pytest in the root directory
  • Semantic version PATCH value must be incremented in pycloudlib/VERSION
  • Ensure all github workflows succeed
  • The final squashed changset should be a single git commit which contains the footer 'Fixes GH-<issue_id>'

Activity

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions