Skip to main content

pymcdc

A Python package to analyze and verify MC/DC (Modified Condition/Decision Coverage) criteria.

V 0.1.1 - add option --cover to manually set requeriment as covered/not covered

V 0.1.3 - allows source file and test file to be in different directories

V 0.2 - do some bug fixes.

V 0.2.1 - 'Don't care' conditions are shown in the requirements lists.

V 0.2.2 - Introduces argument --assert to enable analysis on assert statements.

V 0.2.3 - Fixes the use of not operator and introduces --html argument.

V 0.2.4 - do some bug fixes.

V 0.2.5 - do some bug fixes.

V 0.2.6 - do some bug fixes. HTML file with responsive table headers.

Installation

pip install pymcdc

How to Use

Analyzes the file foo.py and displays the condition combinations that must be satisfied for each decision.By default assert statements are not considered to generate MC/DC requirements. This can be changed with --assert argument.

python -m pymcdc foo.py
python -m pymcdc --assert foo.py

Executes foo.py and shows which MC/DC combinations were covered.

python -m pymcdc --run foo.py

Executes foo.py with arguments ['bar', '1972'] and shows which MC/DC combinations were covered.

python -m pymcdc --run --args "bar 1972" foo.py

Cumulatively runs foo.py and displays the MC/DC combinations covered across multiple runs.

python -m pymcdc --run --append foo.py

Runs foo.py using the test cases defined in test_foo.py.
The --unittest argument can be used multiple times. The --append option is also supported here.

python -m pymcdc --unittest test_foo.py foo.py
python -m pymcdc --unittest tests/test_foo.py src/foo.py

Sets requirement 1 of decision (5,5) as covered and requirement 3 of decision (18,5) as not covered.

python -m pymcdc --cover +5 5 1 -18 5 3 foo.py

Creates an html report in fle html/foo.py/index.html .

python -m pymcdc --html foo.py


### 🔍 Example

```bash
python3 -m pymcdc isleap.py
Line number: (5, 5)
Decicion: a < 1 or a > 9999
Combinations to be covered: 
    | Result.   a < 1    a > 9999   Cover. 
-------------------------------------------
  1 |  False    False     False     False  
  2 |   True    True       ----     False  
  3 |   True    False      True     False  


Covered 0 out of 3 requirements in 1 decisions (0%)
	      
Run time: 0.00052 
python3 -m pymcdc --run isleap.py
Line number: (5, 5)
Decicion: a < 1 or a > 9999
Combinations to be covered: 
    | Result.   a < 1    a > 9999   Cover. 
-------------------------------------------
  1 |  False    False     False      True  
  2 |   True    True       ----     False  
  3 |   True    False      True      True  


Covered 2 out of 3 requirements in 1 decisions (66%)
python3 -m pymcdc --unittest test_isleap.py isleap.py
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

Line number: (5, 5)
Decicion: a < 1 or a > 9999
Combinations to be covered: 
    | Result.   a < 1    a > 9999   Cover. 
-------------------------------------------
  1 |  False    False     False     False  
  2 |   True    True       ----     False  
  3 |   True    False      True      True  


Covered 1 out of 3 requirements in 1 decisions (33%)
python3 -m pymcdc --html test_isleap.py isleap.py
Html file generated at: file:///home/user/mcdc/html/isLeap.py/index.htm

You can also use multiple --path <folder path> to include this folder in the sys.path variable for the interpreter. In this way, imports will also be searched in these folders.

The symbol '----' is used to indicate that the value for that part of the requirement does not matter in the verification. This is due to the language's decision evaluation strategy (short-circuiting).

In the generated HTML file, you can view the combination pairs that ensure each condition is met. To do this, simply click on the desired condition in the table header. To return to the full table, simply click it again.

📝 Notes

  1. The number of MC/DC requirements for a decision with n conditions is not always n+1. It can be slightly larger due to limitations in the computation algorithm.
  2. For decisions with more than 15 conditions, the analysis may take a few minutes. This is only done once.

👤 Author

Marcio Delamaro

📄 License

MIT

🤝 Contributions

Feel free to open issues or submit pull requests!

Metadata

Release files for pymcdc 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymcdc 0.2.6
File Size Uploaded Provenance Actions
pymcdc-0.2.6.tar.gz 20.8 kB Without provenance Details for pymcdc-0.2.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pymcdc 0.2.6
File Interpreter ABI Platform Actions
pymcdc-0.2.6-py3-none-any.whl Python 3 none any Details for pymcdc-0.2.6-py3-none-any.whl

Total release size: 43.3 kB

Release files / pymcdc-0.2.6.tar.gz

Download URL pymcdc-0.2.6.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9a99e56eb2fa520d00e7cb2bd1df73348e1d5e982d5d24d5cca423f9a51dd56d
BLAKE2b-256 checksum
How to use checksums
6f807ef35d51df3929110361171a90f2ac598552aca0c3e5c2019896fd1fa633
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / pymcdc-0.2.6-py3-none-any.whl

Download URL pymcdc-0.2.6-py3-none-any.whl
Size 22.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e2a78fe37a43cc8cd2486d63753b5d87e6766d31b95ce78f723584d565e6b0b
BLAKE2b-256 checksum
How to use checksums
70b1aa914fddb91ef29933799d14da49d426fff7d51effe07c3f1cd75c18f089
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Security for pymcdc 0.2.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page