skillfed

cosmic-ray

Mutation testing

cosmic-ray v8.7.0 362.5K downloads/30d#7,231 on PyPI648
Permissive 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) Active released

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-ray

uv

uv add cosmic-ray

poetry

poetry add cosmic-ray

Installing 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

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Testing

Tags

mutation testing pythontest quality measurementcode mutation analysistest suite effectivenesspython mutation testerverify test coveragemutation score calculator
test-qualitymutation-testingcode-analysis

More Python Modules packages