Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

python3-pip-skeleton with no arguments now returns help #80

Closed
wants to merge 2 commits into from
Closed

Conversation

tizayi
Copy link
Collaborator

@tizayi tizayi commented Mar 17, 2023

python3-pip-skeleton with no arguments now prints help. resolves #79

@codecov
Copy link

codecov bot commented Mar 17, 2023

Codecov Report

Merging #80 (53b09c4) into main (c784df0) will decrease coverage by 1.41%.
The diff coverage is 50.00%.

❗ Current head 53b09c4 differs from pull request most recent head f547bca. Consider uploading reports for the commit f547bca to get more accurate results

@@             Coverage Diff             @@
##              main      #80      +/-   ##
===========================================
- Coverage   100.00%   98.59%   -1.41%     
===========================================
  Files            2        2              
  Lines          138      142       +4     
===========================================
+ Hits           138      140       +2     
- Misses           0        2       +2     
Impacted Files Coverage Δ
src/python3_pip_skeleton/__main__.py 98.55% <50.00%> (-1.45%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@coretl coretl left a comment

Choose a reason for hiding this comment

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

Looks good, please can we have a test for it too?

@tizayi
Copy link
Collaborator Author

tizayi commented Mar 17, 2023

Writing one now what should i compare the output to.

@AlexanderWells-diamond
Copy link
Collaborator

I'd argue that comparing the text output isn't great, as it'll be a bit of a maintenance burden to constantly have to update the test every time you change a command line argument.

Instead, I'd prefer to see a test that simply tries to execute the command line with zero parameters, and then confirm that the parser.print_help() function is called. There's a variety of ways to patch sys.argv, e.g. mock.patch, monkeypatch or unittest.mock, and MagicMocks are good for checking a function has been called. However I do note that the current code structure will make this difficult - as the parser object is created inside the function you can't directly mock it, you'd have to mock the ArgumentParser() constructor to return a mock. Which is doable, but a bit less elegant.

@tizayi tizayi closed this by deleting the head repository Apr 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running python3-pip-skeleton with no arguments generates unhelpful error
3 participants