How to use the mutmut.python_source_files function in mutmut

To help you get started, we’ve selected a few mutmut examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github boxed / mutmut / tests / test_main.py View on Github external
mkdir(entities_dir)

    with open(join(service_dir, 'entities.py'), 'w'):
        pass

    with open(join(service_dir, 'main.py'), 'w'):
        pass

    with open(join(service_dir, 'utils.py'), 'w'):
        pass

    with open(join(entities_dir, 'user.py'), 'w'):
        pass

    # act, assert
    assert set(python_source_files(project_dir, [], paths_to_exclude)) == {
        os.path.join(project_dir, 'services', 'main.py'),
        os.path.join(project_dir, 'services', 'utils.py'),
    }
github boxed / mutmut / tests / test_main.py View on Github external
def test_python_source_files(expected, source_path, tests_dirs, filesystem):
    assert list(python_source_files(source_path, tests_dirs)) == expected
github boxed / mutmut / mutmut / __main__.py View on Github external
def parse_run_argument(argument, config, dict_synonyms, mutations_by_file, paths_to_exclude, paths_to_mutate, tests_dirs):
    if argument is None:
        for path in paths_to_mutate:
            for filename in python_source_files(path, tests_dirs, paths_to_exclude):
                if filename.startswith('test_') or filename.endswith('__tests.py'):
                    continue
                update_line_numbers(filename)
                add_mutations_by_file(mutations_by_file, filename, dict_synonyms, config)
    else:
        try:
            int(argument)
        except ValueError:
            filename = argument
            if not os.path.exists(filename):
                raise click.BadArgumentUsage('The run command takes either an integer that is the mutation id or a path to a file to mutate')
            update_line_numbers(filename)
            add_mutations_by_file(mutations_by_file, filename, dict_synonyms, config)
            return

        filename, mutation_id = filename_and_mutation_id_from_pk(int(argument))