Skip to content

Commit

Permalink
chore: Use pytest-mock in tests (#847)
Browse files Browse the repository at this point in the history
* Add pytest-mock to requirements

* chore: Replace usages of monkeypatch in test_unit.py

* Replace usages of `mock_function` in test_unit.py with `mocker.patch`

* Simplify raising exceptions

* Prefeer `mocker.patch` over `mocker.patch.object`

* Use mocker.stub() for mocking callbacks

* chore: Use pytest-mock in client tests (#848)

* chore: Replaces usages of monkeypatch in test_client.py

* Attempt to use mocker and reset os.remove (#850)

* Attempt to use mocker and reset os.remove

* Use mocker.resetall to reset all mocks

* Use stop (reset is just for the mock call values)

* Fix types: use mocker.stop on remove_mock

---------

Co-authored-by: Trey Hunner <[email protected]>

* Chore/use pytest mock for integration tests (#849)

* Replace some monkeypatch uses with pytest-mock

* Use mocker everywhere in integration tests

Replace all uses of unittest.mock, monkeypatch fixture, and the custom
mock_function fixture with the mocker fixture from pytest-mock.

* Use mocker for mock_function fixture

* Use non-string type annotations for Mock

* Prefer mocker.patch over mocker.patch.object

* Apply suggestions from code review

Co-authored-by: Jakub Fidler <[email protected]>

* Fix variable name typos (mesaage -> message)

* Remove unused mock_function fixture

---------

Co-authored-by: Jakub Fidler <[email protected]>

---------

Co-authored-by: Trey Hunner <[email protected]>
  • Loading branch information
RisingOrange and treyhunner authored Dec 30, 2023
1 parent ad16933 commit 0519834
Show file tree
Hide file tree
Showing 6 changed files with 409 additions and 549 deletions.
1 change: 1 addition & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ vcrpy==4.2.0
pytest-vcr==1.0.2
pytest-qt==4.2.0
pytest-split==0.8.1
pytest-mock==3.12.0
factory-boy==3.2.1
types-factory-boy==0.3.1
pytest-xvfb==2.0.0
Expand Down
1 change: 0 additions & 1 deletion tests/addon/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
install_ah_deck,
mock_all_feature_flags_to_default_values,
mock_download_and_install_deck_dependencies,
mock_function,
mock_message_box_with_cb,
mock_show_dialog_with_cb,
mock_study_deck_dialog_with_cb,
Expand Down
Loading

0 comments on commit 0519834

Please sign in to comment.