Skip to content

Conversation

@BoboTiG
Copy link
Contributor

@BoboTiG BoboTiG commented Jul 23, 2021

I had a look at tests coverage in the context of #1110 and saw 1-2 things that could be quickly tackled.

@codecov-commenter
Copy link

codecov-commenter commented Jul 23, 2021

Codecov Report

Merging #1112 (2017076) into master (aee77a2) will increase coverage by 0.13%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1112      +/-   ##
==========================================
+ Coverage   95.98%   96.11%   +0.13%     
==========================================
  Files          64       64              
  Lines        4107     4096      -11     
==========================================
- Hits         3942     3937       -5     
+ Misses        165      159       -6     
Impacted Files Coverage Δ
httpie/context.py 87.01% <ø> (+0.76%) ⬆️
tests/test_sessions.py 100.00% <ø> (ø)
httpie/output/writer.py 75.43% <50.00%> (ø)
httpie/downloads.py 93.11% <100.00%> (+1.96%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aee77a2...2017076. Read the comment docs.

httpie/core.py Outdated
env=env,
)
parsed_args = parser.parse_args(args=args, env=env)
exit_status = program(args=parsed_args, env=env)
Copy link
Member

Choose a reason for hiding this comment

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

parse_args() and program() each have their own try clause intentionally because we handle different types of exceptions for them. For example, we don’t handle base Exceptions from parse_args() as you can see. We also want to keep the try branches minimal and the distinction explicit. To get rid of the duplicate handling of SystemError and KeyboardInterrupt, something like this would be more in line with the intended behavior:

try:
    parse_args()
    try:
        program()
    except Timeout:
        pass
    except TooManyRedirects:
        pass
    except Exception:
        pass
except KeyboardInterrupt:
    pass
except SystemExit:
    pass

Copy link
Member

@jkbrzt jkbrzt Jul 23, 2021

Choose a reason for hiding this comment

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

This approach would come with the implicit requirement that the outer except types don’t inherit from Exception. So it would need at least a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I removed the commit as it is not really interesting to change that part for now.

@BoboTiG BoboTiG requested a review from jkbrzt July 26, 2021 10:26
@BoboTiG BoboTiG mentioned this pull request Jul 26, 2021
@jkbrzt jkbrzt merged commit 04d05a8 into httpie:master Jul 26, 2021
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.

3 participants