Skip to content

Refactor unittest framework#118

Merged
Davidek523 merged 4 commits intomainfrom
refactor-unittest-framework
May 28, 2025
Merged

Refactor unittest framework#118
Davidek523 merged 4 commits intomainfrom
refactor-unittest-framework

Conversation

@ultimateownsz
Copy link
Collaborator

Pull Request Template

Type of Pull Request

Only check one box per pull request.

  • 🛠️ Code - Changes to the codebase.
  • 🔄 Revert - Reverts a previously merged commit or PR.
  • 📄 Documentation - Updates to documentation files.
  • 🎵 Audio - Changes to audio files.
  • 🎨 Asset - Updates to design or visual assets.

Summary

This PR ... refactors the unit test framework back to pytest, as specified in requirements_dev.txt. This change is useful as it simplified the creation of unit tests easier and adds additional support showing errors during testing.

The update is also needed, to integrate the Hypothesis library, which employs property based testing. Useful for testing edge cases you haven't thought of. Given the ongoing movement rework, associated with issues #103 & #104 which involved libraries such as NumPy and Pathfinding, it could be very useful.

The unit test for the inventory was made by @AnSiChen, I integrated the get_message module in the unit test as well, this change could be better in the future if the inventory gets an overhaul, with mock testing for example, or with the use of Hypothesis to handle specific edge cases.

Related Issues

This PR issue(s)


✅ Checklist:

  • Tested the changes locally.
  • Verified that no breaking changes are introduced.
  • Updated documentation (if applicable).

🏷️ Labels:

type: ..., area: ..., game-..., ...

ultimateownsz and others added 3 commits May 22, 2025 22:24
Refactor inventory tests: migrate from unit test to `pytest` and update test structure

Co-Authored-By: Anthony Em <139152052+AnSiChen@users.noreply.github.com>
Developers on different OSes won’t accidentally introduce line ending changes, keeping the repository history clean.
fix unit test assert
@ultimateownsz ultimateownsz requested a review from Davidek523 May 24, 2025 19:31
A long error in the terminal when you ran ruff, has now been fixed:

`include I` keyword was not found in terminal

ruff check --select I --fix .
Copy link
Collaborator

@Davidek523 Davidek523 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran the tests, everything works fine!

@ultimateownsz
Copy link
Collaborator Author

@Davidek523 If you haven't found any bugs, inconsistency's you can merge it if you want! Note: the all contributor bot doesn't work for some reason, after movement unit tests are done and working, I will create a separate pull request, so we can easily track every change per contributor now and in the future!

@Davidek523 Davidek523 merged commit f183c95 into main May 28, 2025
1 check passed
ultimateownsz added a commit that referenced this pull request May 28, 2025
commit f183c95
Merge: ef6692f 68b393c
Author: Davidek523 <davidov520@wp.pl>
Date:   Wed May 28 11:07:36 2025 +0200

    Refactor unittest framework (#118)

    # Pull Request Template

    ## Type of Pull Request
    Only check one box per pull request.
    - [x] 🛠️ Code - Changes to the codebase.
    - [ ] 🔄 Revert - Reverts a previously merged commit or PR.
    - [ ] 📄 Documentation - Updates to documentation files.
    - [ ] 🎵 Audio - Changes to audio files.
    - [ ] 🎨 Asset - Updates to design or visual assets.

    ## Summary

    <!--
    INSTRUCTIONS:
    - Briefly describe the purpose of this pull request.
    -->

    This PR <!-- adds|modifies|updates|fixes|reverts --> ... <!-- Briefly
    explain what the PR changes. --> refactors the `unit test` framework
    back to `pytest`, as specified in `requirements_dev.txt`. This change is
    useful as it simplified the creation of unit tests easier and adds
    additional support showing errors during testing.

    The update is also needed, to integrate the
    [Hypothesis](https://hypothesis.readthedocs.io/en/latest/index.html)
    library, which employs property based testing. Useful for testing edge
    cases you haven't thought of. Given the ongoing movement rework,
    associated with issues #103 & #104 which involved libraries such as
    NumPy and Pathfinding, it could be very useful.

    The unit test for the inventory was made by @AnSiChen, I integrated the
    `get_message` module in the unit test as well, this change could be
    better in the future if the inventory gets an overhaul, with mock
    testing for example, or with the use of Hypothesis to handle specific
    edge cases.

    ## Related Issues
    <!--
    INSTRUCTIONS:
    - Mention related issue numbers here.
    - Example: "Fixes #123, Closes #456."
    -->

    This PR <!-- fixes|closes|addresses|reverts --> issue(s) <!-- (e.g.,
    Fixes #123, Closes #456) -->

    ---

    ## ✅ Checklist:

    - [x] Tested the changes locally.
    - [x] Verified that no breaking changes are introduced.
    - [ ] Updated documentation (if applicable).

    ## 🏷️ Labels:
    `type: ...`, `area: ...`, `game-...`, ... <!-- Fill and expand on this
    line as needed. See
    https://github.com/PyCeas/Pyceas/wiki/Guide-to-using-labels for more
    information. -->

commit 68b393c
Author: ultimateownsz <saiutechnologies@outlook.com>
Date:   Mon May 26 00:42:51 2025 +0200

    fix ruff import check

    A long error in the terminal when you ran ruff, has now been fixed:

    `include I` keyword was not found in terminal

    ruff check --select I --fix .

commit dac598d
Author: ultimateownsz <saiutechnologies@outlook.com>
Date:   Thu May 22 22:41:04 2025 +0200

    fix ruff issues

    fix unit test assert

commit c910ef1
Author: ultimateownsz <saiutechnologies@outlook.com>
Date:   Thu May 22 22:31:10 2025 +0200

    Create .gitattributes

    Developers on different OSes won’t accidentally introduce line ending changes, keeping the repository history clean.

commit 2955dc5
Author: ultimateownsz <saiutechnologies@outlook.com>
Date:   Thu May 22 22:24:45 2025 +0200

    Refactor inventory unit tests

    Refactor inventory tests: migrate from unit test to `pytest` and update test structure

    Co-Authored-By: Anthony Em <139152052+AnSiChen@users.noreply.github.com>
@ultimateownsz ultimateownsz deleted the refactor-unittest-framework branch May 29, 2025 20:54
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.

2 participants

Comments