cosmic-ray
Mutation testing
What it is and what it does
Cosmic Ray is a mutation testing framework for Python that systematically modifies your source code—changing operators, literals, and control flow—then reruns your test suite to see if the tests catch the mutations. The goal is to measure how well your tests actually validate your code: if a mutation goes undetected, it reveals a gap in test coverage that a passing test count alone would hide.
You configure Cosmic Ray with your test runner and target modules, then let it generate and test mutations. It reports which mutations survived (your tests missed them) and which were killed (your tests caught them), giving you a mutation score that reflects test quality. The tool integrates with common Python testing frameworks and can be run from the command line or embedded in CI/CD pipelines.
Use it for:
- Assess whether your test suite actually validates the code it claims to cover, beyond line coverage metrics.
- Identify weak spots in test logic where mutations slip through undetected.
- Measure test quality improvements over time as you refine your test suite.
- Validate test effectiveness before deploying critical code to production.
- Generate mutation scores for quality gates in continuous integration workflows.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Cosmic Ray is a mutation testing tool that modifies your Python source code and runs your test suite against each mutation to measure test effectiveness and code quality.
Yes, if you want to move beyond line coverage and understand whether your tests actually catch bugs. Cosmic Ray is actively maintained, has low install friction, and uses a permissive MIT license. It's a specialized tool—not for every project—but essential for teams that need confidence in test quality. No known security vulnerabilities.
Install
cosmic-ray on PyPI
pip
pip install cosmic-rayuv
uv add cosmic-raypoetry
poetry add cosmic-rayInstalling cosmic-ray
Before you install
Low install friction with a pure Python wheel. Active maintenance with a recent release (5 days old) and steady repository activity. Supports Python 3.9 through 3.13.
License in practice
MIT license (permissive): you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install cosmic-ray
from cosmic_ray.cli import main
# Then run: cosmic-ray exec --test-runner pytest your_module
Requires Python 3.9 or later and a test runner (pytest, unittest, etc.) configured for your project.
Verify before relying
- Exact mutation types and transformations applied to source code
- Performance characteristics on large codebases or slow test suites
- Integration details with different test runners beyond pytest
Package facts
| License | Copyright (c) 2015-2017 Sixty North AS Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 13 — aiohttp, anybadge, attrs, click, decorator, exit-codes, gitpython, parso, rich, sqlalchemy, stevedore, toml, yattag |
| Maintenance | actively maintained — 5 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 362,484/month — #7,231 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cosmic_ray-8.7.0-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
mutmutMutmut is a mutation testing system for Python…
permissive · top 5,000 on PyPI
pytest-jira-xrayA pytest plugin that marks individual tests…
permissive · top 15,000 on PyPI
atherisAtheris is a coverage-guided fuzzer for Python…
unclear · top 15,000 on PyPI
graphene-file-uploadAdds file upload support to GraphQL mutations…
permissive · top 15,000 on PyPI
varcodeVarcode loads and analyzes genomic variant…
permissive · top 15,000 on PyPI
pytest-raceProvides a pytest fixture that runs test…
permissive · top 15,000 on PyPI
pycarloPycarlo is Monte Carlo's Python SDK for…
permissive · top 5,000 on PyPI
hypothesis-graphqlGenerates arbitrary GraphQL queries matching…
permissive · top 5,000 on PyPI
pytest-rngProvides pytest fixtures that make random…
permissive · top 15,000 on PyPI
python-graphql-clientSends GraphQL queries, mutations, and…
permissive · top 15,000 on PyPI