Add pytest number guessing game - #42
Open
Nonoka-T wants to merge 3 commits into
Open
Conversation
Contributor
Author
|
@sehmaluva Hi, I added a pytest to your Number Guessing Game. Please kindly check this PR. Thank you so much! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Description
This PR adds a pytest test suite for the Number Guessing Game challenge.
What type of contribution is this?
What does this PR do?
This PR adds pytest tests for the testable logic functions in sehmaluva_number_guessing_game.py. Functions that rely on input() such as select_difficulty and get_guess were intentionally excluded since they require interactive user input.
Related Issue
🎯 For Beginners: Step-by-Step Guide
Before Submitting
✅ I have tested my changes locally
✅ I have followed the project guidelines
✅ I have updated documentation (if needed)
Need Help?
🧪 Testing
How to test this PR?
Test Results
📸 Screenshots / Demo
Before
After
📝 Checklist
Code Quality
Documentation
/docsTesting & Validation
Git & Commit
🎓 For Different Contribution Types
📱 Profile Contributions
Profile Checklist
docs/templates/PROFILE_TEMPLATE.mdprofiles/YOUR_GITHUB_USERNAME.mdProfile Tips
🧩 Challenge Solutions
Challenge Checklist
challenges/level/challenge-name/)Challenge Tips
🚀 Project Contributions
Project Checklist
Project Tips
📝 Documentation
Documentation Checklist
Documentation Tips
🌟 Additional Information
What I learned while working on this:
How to separate "pure logic" functions which take inputs and return outputs like calculate_score from interactive functions which rely on input() so that the pure logic can be tested without simulating user input.
Challenges I faced:
Since the solution file is in a different folder than the test file, I needed to use sys.path.insert to make the import work correctly.
Questions for reviewers:
📚 Resources I Used
💬 Notes for Reviewers