Metadata-Version: 2.1
Name: mutatest
Version: 1.0.1
Summary: Python mutation testing: test your tests!
Home-page: https://github.com/EvanKepner/mutatest
Author: Evan Kepner
Author-email: EvanKepner@users.noreply.github.com
Maintainer: Evan Kepner
License: MIT
Project-URL: Documentation, https://mutatest.readthedocs.io/
Project-URL: Bug Tracker, https://github.com/EvanKepner/mutatest/issues
Project-URL: Source Code, https://github.com/EvanKepner/mutatest
Keywords: mutatest,mutation,testing,test,mutant,mutate,pytest
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Environment :: Console
Classifier: Framework :: Pytest
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Software Development :: Testing :: Unit
Requires-Python: >=3.7.0
Requires-Dist: coverage (>=4.4)
Provides-Extra: dev
Requires-Dist: pytest (>=4.0.0) ; extra == 'dev'
Requires-Dist: freezegun ; extra == 'dev'
Requires-Dist: coverage ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: pytest-xdist ; extra == 'dev'
Requires-Dist: tox ; extra == 'dev'
Requires-Dist: virtualenv ; extra == 'dev'
Requires-Dist: hypothesis ; extra == 'dev'
Requires-Dist: ipython ; extra == 'dev'
Requires-Dist: sphinx ; extra == 'dev'
Requires-Dist: mypy ; extra == 'dev'
Requires-Dist: black ; extra == 'dev'
Requires-Dist: pre-commit ; extra == 'dev'
Requires-Dist: isort ; extra == 'dev'
Provides-Extra: docs
Requires-Dist: coverage ; extra == 'docs'
Requires-Dist: ipython ; extra == 'docs'
Requires-Dist: sphinx ; extra == 'docs'
Provides-Extra: qa
Requires-Dist: mypy ; extra == 'qa'
Requires-Dist: black ; extra == 'qa'
Requires-Dist: pre-commit ; extra == 'qa'
Requires-Dist: isort ; extra == 'qa'
Provides-Extra: tests
Requires-Dist: pytest (>=4.0.0) ; extra == 'tests'
Requires-Dist: freezegun ; extra == 'tests'
Requires-Dist: coverage ; extra == 'tests'
Requires-Dist: pytest-cov ; extra == 'tests'
Requires-Dist: pytest-xdist ; extra == 'tests'
Requires-Dist: tox ; extra == 'tests'
Requires-Dist: virtualenv ; extra == 'tests'
Requires-Dist: hypothesis ; extra == 'tests'

``mutatest``: Python mutation testing
==========================================


.. image:: https://img.shields.io/badge/Python_version-3.7-green.svg
    :target: https://www.python.org/
.. image:: https://travis-ci.org/EvanKepner/mutatest.svg?branch=master
    :target: https://travis-ci.org/EvanKepner/mutatest
.. image:: https://readthedocs.org/projects/mutatest/badge/?version=latest
    :target: https://mutatest.readthedocs.io/en/latest/?badge=latest
.. image:: https://codecov.io/gh/EvanKepner/mutatest/branch/master/graph/badge.svg
  :target: https://codecov.io/gh/EvanKepner/mutatest
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/ambv/black
.. image:: https://pepy.tech/badge/mutatest
    :target: https://pepy.tech/project/mutatest



Are you confident in your tests? Try out ``mutatest`` and see if your tests will detect small
modifications (mutations) in the code. Surviving mutations represent subtle changes that are
undetectable by your tests. These mutants are potential modifications in source code that continuous
integration checks would miss.


Features
---------

    - Simple command line tool with multiple configuration options.
    - Built on Python's Abstract Syntax Tree (AST) grammar to ensure mutants are valid.
    - No source code modification, only the ``__pycache__`` is changed.
    - Uses ``coverage`` to create only meaningful mutants.
    - Built for efficiency with multiple running modes and random sampling of mutation targets.
    - Flexible enough to run on a whole package or a single file.
    - Includes an API for custom mutation controls.

.. code-block:: bash

    $ mutatest -s example/ -t "pytest" -r 314

    Running clean trial
    2 mutation targets found in example/a.py AST.
    1 mutation targets found in example/b.py AST.
    Setting random.seed to: 314
    Total sample space size: 2
    10 exceeds sample space, using full sample: 2.

    Starting individual mutation trials!
    Current target location: a.py, LocIndex(ast_class='BinOp', lineno=6, col_offset=11, op_type=<class '_ast.Add'>)
    Detected mutation at example/a.py: (6, 11)
    Detected mutation at example/a.py: (6, 11)
    Surviving mutation at example/a.py: (6, 11)
    Break on survival: stopping further mutations at location.

    Current target location: b.py, LocIndex(ast_class='CompareIs', lineno=6, col_offset=11, op_type=<class '_ast.Is'>)
    Detected mutation at example/b.py: (6, 11)
    Running clean trial

    Mutatest diagnostic summary
    ===========================
     - Source location: /home/zassoc/Github/mutatest/docs/api_tutorial/example
     - Test commands: ['pytest']
     - Mode: s
     - Excluded files: []
     - N locations input: 10
     - Random seed: 314

    Random sample details
    ---------------------
     - Total locations mutated: 2
     - Total locations identified: 2
     - Location sample coverage: 100.00 %


    Running time details
    --------------------
     - Clean trial 1 run time: 0:00:00.348999
     - Clean trial 2 run time: 0:00:00.350213
     - Mutation trials total run time: 0:00:01.389095

    2019-10-17 16:57:08,645: Trial Summary Report:

    Overall mutation trial summary
    ==============================
     - DETECTED: 3
     - SURVIVED: 1
     - TOTAL RUNS: 4
     - RUN DATETIME: 2019-10-17 16:57:08.645355

    2019-10-17 16:57:08,645: Detected mutations:

    DETECTED
    --------
     - example/a.py: (l: 6, c: 11) - mutation from <class '_ast.Add'> to <class '_ast.Sub'>
     - example/a.py: (l: 6, c: 11) - mutation from <class '_ast.Add'> to <class '_ast.Mod'>
     - example/b.py: (l: 6, c: 11) - mutation from <class '_ast.Is'> to <class '_ast.IsNot'>

    2019-10-17 16:57:08,645: Surviving mutations:

    SURVIVED
    --------
     - example/a.py: (l: 6, c: 11) - mutation from <class '_ast.Add'> to <class '_ast.Mult'>


Documentation
-------------
For full documentation, including installation, CLI references, API references, and tutorials,
please see https://mutatest.readthedocs.io/en/latest/.
The project is hosted on PyPI at https://pypi.org/project/mutatest/.


Bugs/Requests
-------------

Please use the `GitHub issue tracker <https://github.com/EvanKepner/mutatest/issues>`_ to submit bugs
or request features.
See `Contributing Guidelines <https://mutatest.readthedocs.io/en/latest/contributing.html>`_ if you
are interested in submitting code in the form of pull requests.

ChangeLog
---------

Consult the `Changelog <https://mutatest.readthedocs.io/en/latest/changelog.html>`_ page for fixes
and enhancements of each version.

License
-------

Copyright Evan Kepner 2018-2019.

Distributed under the terms of the `MIT`_ license, ``mutatest`` is free and open source software.

.. _`MIT`: https://github.com/pytest-dev/pytest/blob/master/LICENSE


Changelog
=========

Beta Releases
-------------

1.0.1
-----

    - Documentation updates, including the API tutorial.
    - Fix on latest ``mypy`` errors related to ``strict`` processing of ``run`` and ``cache``.


1.0.0
~~~~~

    - Moving from the alpha to the beta version with an API design. The alpha releases were focused
      on defining the functionality of the CLI. In the beta version, the CLI remains unchanged; however,
      a full internal design has been applied to create a coherent API. The ``controller``, ``optimizers``,
      and ``maker`` modules have been fully replaced by ``run``, ``api``, and ``filters``. See
      the new full API documentation for details on using these modules outside of the CLI.
    - Additionally, ``pytest`` was removed from the installation requirements since it is assumed
      for the default running modes but not required for the API or installation.


Alpha Releases
--------------

0.9.2
~~~~~

    - Added ``--exception`` and ``-x`` as a survivor tolerance to raise an exception
      after the trial completes if the count of surviving mutants is greater than or equal to the
      specified value.

0.9.1
~~~~~

    - Added ``--whitelist`` and ``--blacklist`` with category codes for mutation families.
    - Provides CLI selection of mutation types to be used during the trials.


0.9.0
~~~~~

    - Added new ``If`` mutation:
        1. Original statements are represented by ``If_Statement`` and mutated to be either
           ``If_True`` where the statement always passes, or ``If_False`` where the statement
           is never passed.


0.8.0
~~~~~

    - Breaking changes to the CLI arguments and new defaults:
        1. Output files are now optional, the default behavior has changed from always writing an RST
           file using the ``-o`` option on the command line.
        2. Exclusions are still marked as ``-e``; however, now multiple ``-e`` arguments are
           supported and arguments must point to a Python file. The argument used to be:
           ``mutatest -e "__init__.py _devtools.py"`` and now it is
           ``mutatest -e src/__init__.py -e src/_devtools.py``. There are no longer default
           exclusions applied.

    - Improved CLI reporting, including selected test counts and line/col locations
      for trial results while processing.


0.7.1
~~~~~

    - Internal changes to ``Slice`` mutations for clearer categorization and report output.
    - Includes clearing names to ``Slice_Swap`` and ``Slice_RangeChange`` for categories.
    - Updates operation names to ``Slice_Unbounded...`` with "lower" or "upper".

0.7.0
~~~~~

    - Added new slice mutations:
        1. ``Slice_SwapNoneUL`` and ``Slice_SwapNoneLU`` for swapping the upper and lower
           bound values when only one is specified e.g. ``x[1:]`` to ``x[:1]``.
        2. ``Slice_UPosToZero`` and ``Slice_UNegToZero`` for moving the upper bound of a
           slice by 1 unit e.g. ``x[1:5]`` becomes ``x[1:4]``.


0.6.1
~~~~~

    - Added explicit tests for ``argparse`` cli options.
    - Added mechanism to sort reporting mutations by source file, then line number, then column
      number.

0.6.0
~~~~~

    - Including ``pytest`` in the installation requirements. Technically, any test runner can
      be used but with all base package assumptions being built around ``pytest`` this feels
      like the right assumption to call out as an install dependency. It is the default behavior.
    - Updated ``controller`` for test file exclusion to explicitly match prefix or suffix cases
      for ``"test_"`` and ``"_test"`` per ``pytest`` conventions.
    - Changed error and unknown status results to console color as yellow instead of red.
    - Added multiple invariant property tests, primarily to ``controller`` and ``cache``.
    - Added ``hypothesis`` to the test components of ``extras_require``.
    - Moved to ``@property`` decorators for internal class properties that should only
      be set at initialization, may add custom ``setters`` at a later time.
    - Fixed a zero-division bug in the ``cli`` when reporting coverage percentage.

0.5.0
~~~~~

    - Addition of ``optimizers``, including the new class ``CoverageOptimizer``.
    - This optimizer restricts the full sample space only to source locations that are marked
      as covered in the ``.coverage`` file. If you have a ``pytest.ini`` that includes
      the ``--cov=`` command it will automatically generate during the clean-trial run.


0.4.2
~~~~~

    - More behind the scenes maintenance: updated debug level logging to include source file
      names and line numbers for all visit operations and separated colorized output to a new
      function.

0.4.1
~~~~~

    - Updated the reporting functions to return colorized display results to CLI.

0.4.0
~~~~~

    - Added new mutation support for:
        1. ``AugAssign`` in AST e.g. ``+= -= *= /=``.
        2. ``Index`` substitution in lists e.g. take a positive number like ``i[1]`` and
           mutate to zero and a negative number e.g. ``i[-1] i[0]``.

    - Added a ``desc`` attribute to ``transformers.MutationOpSet`` that is used in the
      cli help display.
    - Updated the cli help display to show the description and valid members.

0.3.0
~~~~~

    - Added new mutation support for ``NameConstant`` in AST.
    - This includes substitutions for singleton assignments such as: ``True``, ``False``,
      and ``None``.
    - This is the first non-type mutation and required adding a ``readonly`` parameter
      to the ``transformers.MutateAST`` class. Additionally, the type-hints for the
      ``LocIndex`` and ``MutationOpSet`` were updated to ``Any`` to support
      the mixed types. This was more flexible than a series of ``overload`` signatures.

0.2.0
~~~~~

    - Added new compare mutation support for:
        1. ``Compare Is`` mutations e.g. ``is, is not``.
        2. ``Compare In`` mutations e.g. ``in, not in``.

0.1.0
~~~~~

    - Initial release!
    - Requires Python 3.7 due to the ``importlib`` internal references for manipulating cache.
    - Run mutation tests using the ``mutatest`` command line interface.
    - Supported operations:

        1. ``BinOp`` mutations e.g. ``+ - / *`` including bit-operations.
        2. ``Compare`` mutations e.g. ``== >= < <= !=``.
        3. ``BoolOp`` mutations e.g. ``and or``.


Authors
=======

* Evan Kepner


