Skip to content

Simple, Elegant, Typed Argument Parsing with argparse

License

Notifications You must be signed in to change notification settings

noracai26/SimpleParsing

 
 

Repository files navigation

Report for Assignment 1

Project chosen

Name: SimpleParsing

URL: https://github.com/lebrice/SimpleParsing

Number of lines of code and the tool used to count it: lizard, 18161 nloc

Programming language: Python

Coverage measurement

Existing tool

Coverage.py via the command: coverage run -m pytest

image

Your own coverage tool

Karina Sudnicina

Function 1 name: get_bound(t) from simple_parsing/utils.py

image

Function 2 name: _description_from_docstring(docstring: dp.Docstring) from simple_parsing/decorators.py

image


Nora Cai

Function 1 name: def post_init from examples/ugly_example_after.py

15C6B39A-F85B-40D7-868A-BD7814146D84_4_5005_c

D44E1447-744E-4E90-9AB9-66AD85D8B659_4_5005_c

Function 2 name: def contains_dataclass_type_arg from simple_parsing/utils.py

15C6B39A-F85B-40D7-868A-BD7814146D84_4_5005_c

A5692BBC-EAA6-45F5-AE32-596AAD60B2AC_4_5005_c


Che Lai

Function 1 name: def setattr_recursive from simple_parsing/utils.py

3891718737517_ pic

3841718649695_ pic

Function 2 name: def getattr_recursive from simple_parsing/utils.py

3901718737537_ pic

3841718649695_ pic


Sanne Aerts

Function 1: get_item_type from simple_parsing/utils.py

The instrumented function image

Coverage results output from the instrumentation
image

Function 2: get_argparse_type_for_container from simple_parsing/utils.py

The instrumented function
image

Coverage results output from the instrumentation
image


Coverage improvement

Individual tests

Karina Sudnicina

Test 1: get_bound(t)

Coverage before:
get_bound without tests
Coverage after:
get_bound with tests

As seen from the screenshot, the function was initially not covered completely by test cases. I have added the test cases to make sure all of the brances are covered. As a result, the function is covered by 100% and the number of 'missing' statements in utils.py got decreased by 1 - from 77 to 76.



Test 2: def _description_from_docstring(docstring: dp.Docstring)

Coverage before:
description_from_docstring_before Coverage after:
description_from_docstring_after

Similarly, the function was not covered completely. Adding new test cases for this function raised the coverage of decorators.py file for 2% - from 91 to 93. The function is now covered by 100% and the 'missing' statements number has also decreased by 1 - from 6 to 5.



Nora Cai

Test 1: test/test_ugly_example_after.py

added new test:

DE6C58C0-C52B-40B5-8FB7-492B1ADDBE97

old coverage:

A3D1D742-6072-4379-B4FC-7C709D595299_4_5005_c

new coverage:

77EEF328-316B-4EC1-8183-7A21D9A2FEFC_4_5005_c

percentage of improvement: 60%%

9CFFF73C-F44B-43ED-A9A1-A718B839F63F_4_5005_c

0BE40E06-0EC0-4DB6-BD22-32BBABD08BD1_4_5005_c

The coverage of the function def post_init went from 40% to 100%, this is because the coverage for the function has been improved by writing test case to cover the second and third branch, which were not previously covered.

Test 2: test/test_base.py

enhanced existing test:

00CC657A-5AB9-4523-ADE5-21180F44985F

old coverage:

AB405694-D254-4802-8724-270B2223A4C7_4_5005_c

new coverage:

B76F7C5B-6034-4358-B9F4-A651EDDD191A_4_5005_c

percentage of improvement: 14%

31650BE9-DBBD-426C-96AC-FE910953B826_4_5005_c

EE3DB7E3-22FD-4476-8F6D-EAD10AAFF1D4_4_5005_c

The coverage of the function def contains_dataclass_type_arg went from 86% to 100%, the increase is caused by the enhancement of test cases that that covers the second branch of the function, which was not previously covered.



Che Lai

Test 1: setattr_recursive

old coverage results: (coverage: 0%) 3871718651183_ pic

3851718651108_ pic

new coverage results: (coverage: 100%) 3971718738756_ pic

3941718738557_ pic

In the original test file, there was no test case for this function, so the coverage of this function was 0%, then I added the test code for this function, then its coverage increased to 100%.

Test 2: getattr_recursive

old coverage results: (coverage: 0%)

3931718738438_ pic

3861718651118_ pic

new coverage results: (coverage: 100%) 3961718738689_ pic

3951718738569_ pic

percentage of improvement: 100%

Same as the function in Test 1, there was no test case for this function, so the old covearage was 0%, after I added test case for it, the coverage of this function increased to 100%.



Sanne Aerts

Test 1: New test for Function 1 (get_item_type from simple_parsing/utils.py) to hit the third branch. image

Old coverage result

image image image

New coverage result

image image image

Adding a new test case to cover the third branch of the function resulted in a coverage improvement of 17%, bringing the total coverage for the function to 100%. image image

Test 2: New test for Function 2 (get_argparse_type_for_container from simple_parsing/utils.py) to hit the second branch.

Old coverage result

image image image

New coverage result

image image image

Adding a new test case to cover the second branch of the function resulted in a coverage improvement of 11%, bringing the total coverage for the function to 100%. image image

Overall

Old result:

image

New result:

2A7F713D-C56E-4102-AF34-E26632752FA7

Statement of individual contributions

Karina Sudnicina: found the project, implemented coverage tool for two functions mentioned above, created a test cases for them.

Nora Cai: implemeted coverage tool for two functions mentioned above, created test cases for them.

Sanne Aerts: Created a function-based coverage tool for two chosen functions and developed new test cases for them to enhance their coverage.

Che Lai: imlemented coverage tool for two functions and enhance their coverage by creating new test cases.

About

Simple, Elegant, Typed Argument Parsing with argparse

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%