repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
black | tests/data/miscellaneous/string_quotes.py | .py | ''''''
'\''
'"'
"'"
"\""
"Hello"
"Don't do that"
'Here is a "'
'What\'s the deal here?'
"What's the deal \"here\"?"
"And \"here\"?"
"""Strings with "" in them"""
'''Strings with "" in them'''
'''Here's a "'''
'''Here's a " '''
'''Just a normal triple
quote'''
f"just a normal {f} string"
f'''This is a triple-quoted {f}... | 115 | 2,363 |
black | tests/data/miscellaneous/python2_detection.py | .py | # This uses a similar construction to the decorators.py test data file FYI.
print "hello, world!"
###
exec "print('hello, world!')"
###
def set_position((x, y), value):
pass
###
try:
pass
except Exception, err:
pass
###
raise RuntimeError, "I feel like crashing today :p"
###
`wow_these_really_did... | 90 | 758 |
black | tests/data/miscellaneous/invalid_header.py | .py | This is not valid Python syntax
y = "This is valid syntax"
| 3 | 59 |
black | tests/data/miscellaneous/debug_visitor.py | .py | @dataclass
class DebugVisitor(Visitor[T]):
tree_depth: int = 0
def visit_default(self, node: LN) -> Iterator[T]:
indent = ' ' * (2 * self.tree_depth)
if isinstance(node, Node):
_type = type_repr(node.type)
out(f'{indent}{_type}', fg='yellow')
self.tree_depth ... | 33 | 1,193 |
black | scripts/fuzz.py | .py | """Property-based tests for Black.
By Zac Hatfield-Dodds, based on my Hypothesmith tool for source code
generation. You can run this file with `python`, `pytest`, or (soon)
a coverage-guided fuzzer I'm working on.
"""
import hypothesmith
from hypothesis import HealthCheck, given, settings
from hypothesis import stra... | 74 | 2,714 |
black | scripts/check_version_in_basics_example.py | .py | """
Check that the rev value in the example from ``the_basics.md`` matches
the latest version of Black. This saves us from forgetting to update that
during the release process.
"""
import os
import sys
import commonmark
from bs4 import BeautifulSoup
def main(changes: str, the_basics: str) -> None:
changes_html ... | 55 | 1,782 |
black | scripts/generate_schema.py | .py | import json
from typing import IO, Any
import click
import black
def generate_schema_from_click(
cmd: click.Command,
) -> dict[str, Any]:
result: dict[str, dict[str, Any]] = {}
for param in cmd.params:
if not isinstance(param, click.Option) or param.is_eager:
continue
assert... | 76 | 2,423 |
black | scripts/release_tests.py | .py | #!/usr/bin/env python3
import unittest
from pathlib import Path
from shutil import rmtree
from tempfile import TemporaryDirectory
from typing import Any
from unittest.mock import Mock, patch
from release import SourceFiles, tuple_calver # type: ignore
class FakeDateTime:
"""Used to mock the date to test genera... | 70 | 2,333 |
black | scripts/migrate-black.py | .py | #!/usr/bin/env python3
# check out every commit added by the current branch, blackify them,
# and generate diffs to reconstruct the original commits, but then
# blackified
import logging
import os
import sys
from subprocess import PIPE, Popen, check_output, run
def git(*args: str) -> str:
return check_output(["gi... | 97 | 2,979 |
black | scripts/release.py | .py | #!/usr/bin/env python3
"""
Tool to help automate changes needed in commits during and after releases
"""
from __future__ import annotations
import argparse
import logging
import re
import sys
from datetime import datetime
from pathlib import Path
from subprocess import run
LOG = logging.getLogger(__name__)
NEW_VERS... | 249 | 7,654 |
black | scripts/diff_shades_gha_helper.py | .py | """Helper script for psf/black's diff-shades Github Actions integration.
diff-shades is a tool for analyzing what happens when you run Black on
OSS code capturing it for comparisons or other usage. It's used here to
help measure the impact of a change *before* landing it (in particular
posting a comment on completion ... | 232 | 8,034 |
black | scripts/check_pre_commit_rev_in_example.py | .py | """
Check that the rev value in the example pre-commit configuration matches
the latest version of Black. This saves us from forgetting to update that
during the release process.
Why can't we just use `rev: stable` and call it a day? Well pre-commit
won't auto update the hook as you may expect (and for good reasons, s... | 64 | 2,190 |
black | action/main.py | .py | import os
import re
import shlex
import shutil
import sys
from pathlib import Path
from subprocess import PIPE, STDOUT, run
ACTION_PATH = Path(os.environ["GITHUB_ACTION_PATH"])
ENV_PATH = ACTION_PATH / ".black-env"
ENV_BIN = ENV_PATH / ("Scripts" if sys.platform == "win32" else "bin")
OPTIONS = os.getenv("INPUT_OPTION... | 202 | 6,269 |
black | profiling/dict_big.py | .py | config = some.Structure(
some_mapping={
"00501": "AB890X",
"00544": "AB890X",
"01001": "AB889X",
"01002": "AB889X",
"01003": "AB889X",
"01004": "AB889X",
"01005": "AB889X",
"01007": "AB889X",
"01008": "AB889X",
"01009": "AB889X",
... | 8,002 | 215,971 |
black | profiling/mix_big.py | .py | config = some.Structure(
globalMap = {
103310322020340: [100000031211103,101042000320420,100100001202021,112320301100420,110101024402203,112001202000203,112101112010031,102130400200010,100401014300441,103000401422033],
110040120003212: [114413100031332,102101001412002,100210000032130,214000110100040... | 1,003 | 184,224 |
black | profiling/mix_small.py | .py | config = some.Structure(
globalMap = {
103310322020340: [100000031211103,101042000320420,100100001202021,112320301100420,110101024402203,112001202000203,112101112010031,102130400200010,100401014300441,103000401422033],
110040120003212: [114413100031332,102101001412002,100210000032130,214000110100040... | 103 | 18,306 |
black | profiling/list_big.py | .py | config = some.Structure(
value=set([u'some_rather_long_text_value',
u'some_rather_long_text_value',
u'some_rather_long_text_value',
u'some_rather_long_text_value',
u'some_rather_long_text_value',
u'some_rather_long_text_value',
u'some_rather_long_text_value',
... | 4,001 | 159,994 |
black | src/black/files.py | .py | import io
import os
import sys
from collections.abc import Iterable, Iterator, Sequence
from functools import lru_cache
from pathlib import Path
from re import Pattern
from typing import TYPE_CHECKING, Any, Union
from mypy_extensions import mypyc_attr
from packaging.specifiers import InvalidSpecifier, Specifier, Speci... | 436 | 14,921 |
black | src/black/strings.py | .py | """
Simple formatting on strings. Further string formatting code is in trans.py.
"""
import re
import sys
from functools import lru_cache
from re import Match, Pattern
from typing import Final
from black._width_table import WIDTH_TABLE
from blib2to3.pytree import Leaf
STRING_PREFIX_CHARS: Final = "fturbFTURB" # All... | 409 | 13,967 |
black | src/black/_width_table.py | .py | # Generated by make_width_table.py
# wcwidth 0.2.14
# Unicode 17.0.0
from typing import Final
WIDTH_TABLE: Final[list[tuple[int, int, int]]] = [
(4352, 4447, 2),
(8986, 8987, 2),
(9001, 9002, 2),
(9193, 9196, 2),
(9200, 9200, 2),
(9203, 9203, 2),
(9725, 9726, 2),
(9748, 9749, 2),
(9... | 133 | 3,096 |
black | src/black/linegen.py | .py | """
Generating lines of code.
"""
import re
import sys
from collections.abc import Collection, Iterable, Iterator
from dataclasses import replace
from enum import Enum, auto
from functools import partial, wraps
from typing import Union, cast
from black.brackets import (
COMMA_PRIORITY,
COMPARATOR_PRIORITY,
... | 2,253 | 88,220 |
black | src/black/numerics.py | .py | """
Formatting numeric literals.
"""
from blib2to3.pytree import Leaf
def format_hex(text: str) -> str:
"""
Formats a hexadecimal string like "0x12B3"
"""
before, after = text[:2], text[2:]
return f"{before}{after.upper()}"
def format_scientific_notation(text: str) -> str:
"""Formats a nume... | 64 | 1,753 |
black | src/black/nodes.py | .py | """
blib2to3 Node/Leaf transformation-related utility functions.
"""
from collections.abc import Iterator
from typing import Final, Generic, Literal, TypeGuard, TypeVar, Union
from mypy_extensions import mypyc_attr
from black.cache import CACHE_DIR
from black.mode import Mode, Preview
from black.strings import get_s... | 1,145 | 33,931 |
black | src/black/output.py | .py | """Nice output for Black.
The double calls are for patching purposes in tests.
"""
import json
import os
import re
import tempfile
from typing import Any
from click import echo, style
from mypy_extensions import mypyc_attr
@mypyc_attr(patchable=True)
def _out(message: str | None = None, nl: bool = True, **styles: ... | 136 | 4,204 |
black | src/black/concurrency.py | .py | """
Formatting many files at once via multiprocessing. Contains entrypoint and utilities.
NOTE: this module is only imported if we need to format several files at once.
"""
from __future__ import annotations
import asyncio
import logging
import os
import signal
import sys
import traceback
from collections.abc import... | 237 | 8,111 |
black | src/black/__main__.py | .py | from black import patched_main
patched_main()
| 4 | 47 |
black | src/black/__init__.py | .py | import io
import json
import platform
import re
import sys
import tokenize
import traceback
from collections.abc import (
Collection,
Generator,
MutableMapping,
Sequence,
)
from contextlib import nullcontext
from dataclasses import replace
from datetime import datetime, timezone
from enum import Enum
fr... | 1,723 | 56,269 |
black | src/black/lines.py | .py | import itertools
import math
from collections.abc import Callable, Iterator, Sequence
from dataclasses import dataclass, field
from typing import NamedTuple, Optional, TypeVar, Union, cast
from black.brackets import COMMA_PRIORITY, DOT_PRIORITY, BracketTracker
from black.mode import Mode, Preview
from black.nodes impo... | 1,736 | 68,888 |
black | src/black/debug.py | .py | from collections.abc import Iterator
from dataclasses import dataclass, field
from typing import Any, TypeVar, Union
from black.nodes import Visitor
from black.output import out
from black.parsing import lib2to3_parse
from blib2to3.pgen2 import token
from blib2to3.pytree import Leaf, Node, type_repr
LN = Union[Leaf, ... | 56 | 1,922 |
black | src/black/comments.py | .py | import re
from collections.abc import Collection, Iterator
from dataclasses import dataclass
from functools import lru_cache
from typing import Final, Union
from black.mode import Mode
from black.nodes import (
CLOSING_BRACKETS,
OPENING_BRACKETS,
STANDALONE_COMMENT,
STATEMENT,
WHITESPACE,
conta... | 946 | 34,642 |
black | src/black/ranges.py | .py | """Functions related to Black's formatting by line ranges feature."""
import difflib
from collections.abc import Collection, Iterator, Sequence
from dataclasses import dataclass
from black.nodes import (
LN,
STANDALONE_COMMENT,
Leaf,
Node,
Visitor,
first_leaf,
furthest_ancestor_with_last_l... | 638 | 25,579 |
black | src/black/mode.py | .py | """Data structures configuring Black behavior.
Mostly around Python language feature support per version and Black configuration
chosen by the user.
"""
from dataclasses import dataclass, field
from enum import Enum, auto
from hashlib import sha256
from operator import attrgetter
from typing import Final
from black.... | 356 | 11,456 |
black | src/black/schema.py | .py | import importlib.resources
import json
from typing import Any
def get_schema(tool_name: str = "black") -> Any:
"""Get the stored complete schema for black's settings."""
assert tool_name == "black", "Only black is supported."
pkg = "black.resources"
fname = "black.schema.json"
schema = importlib... | 16 | 431 |
black | src/black/parsing.py | .py | """
Parse Python code and perform AST validation.
"""
import ast
import sys
import warnings
from collections.abc import Collection, Iterator
from black.mode import VERSION_TO_FEATURES, Feature, TargetVersion, supports_feature
from black.nodes import syms
from blib2to3 import pygram
from blib2to3.pgen2 import driver
f... | 296 | 10,051 |
black | src/black/trans.py | .py | """
String transformers that can split and merge strings.
"""
import re
from abc import ABC, abstractmethod
from collections import defaultdict
from collections.abc import Callable, Collection, Iterable, Iterator, Sequence
from dataclasses import dataclass
from typing import Any, ClassVar, Final, Literal, TypeVar, Uni... | 2,617 | 100,252 |
black | src/black/cache.py | .py | """Caching of formatted files with feature-based invalidation."""
import hashlib
import os
import pickle
import sys
import tempfile
from collections.abc import Iterable
from dataclasses import dataclass, field
from pathlib import Path
from typing import NamedTuple
from platformdirs import user_cache_dir
from _black_... | 157 | 4,876 |
black | src/black/rusty.py | .py | """An error-handling model influenced by that used by the Rust programming language
See https://doc.rust-lang.org/book/ch09-00-error-handling.html.
"""
from typing import Generic, TypeVar, Union
T = TypeVar("T")
E = TypeVar("E", bound=Exception)
class Ok(Generic[T]):
def __init__(self, value: T) -> None:
... | 29 | 557 |
black | src/black/handle_ipynb_magics.py | .py | """Functions to process IPython magics with."""
import ast
import collections
import dataclasses
import re
import secrets
import string
from collections.abc import Collection
from functools import lru_cache
from importlib.util import find_spec
from typing import TypeGuard
from black.mode import Mode
from black.output... | 516 | 15,901 |
black | src/black/const.py | .py | DEFAULT_LINE_LENGTH = 88
DEFAULT_EXCLUDES = r"/(\.direnv|\.eggs|\.git|\.hg|\.ipynb_checkpoints|\.mypy_cache|\.nox|\.pytest_cache|\.ruff_cache|\.tox|\.svn|\.venv|\.vscode|__pypackages__|_build|buck-out|build|dist|venv)/" # noqa: B950
DEFAULT_INCLUDES = r"(\.pyi?|\.ipynb)$"
STDIN_PLACEHOLDER = "__BLACK_STDIN_FILENAME__"... | 5 | 321 |
black | src/black/brackets.py | .py | """Builds on top of nodes.py to track brackets."""
from collections.abc import Iterable, Iterator, Sequence
from dataclasses import dataclass, field
from typing import Final, Union
from black.nodes import (
BRACKET,
CLOSING_BRACKETS,
COMPARATORS,
LOGIC_OPERATORS,
MATH_OPERATORS,
OPENING_BRACKE... | 430 | 14,584 |
black | src/black/report.py | .py | """
Summarize Black runs to users.
"""
from dataclasses import dataclass
from enum import Enum
from pathlib import Path
from black.output import err, out, style_output
from black.parsing import InvalidInput
class Changed(Enum):
NO = 0
CACHED = 1
YES = 2
class NothingChanged(UserWarning):
"""Raised... | 123 | 3,973 |
black | src/blackd/middlewares.py | .py | from collections.abc import Awaitable, Callable, Collection, Iterable
from aiohttp import web
from aiohttp.typedefs import Middleware
from aiohttp.web_middlewares import middleware
from aiohttp.web_request import Request
from aiohttp.web_response import StreamResponse
Handler = Callable[[Request], Awaitable[StreamRes... | 46 | 1,487 |
black | src/blackd/__main__.py | .py | import blackd
blackd.patched_main()
| 4 | 37 |
black | src/blackd/__init__.py | .py | import asyncio
import logging
import os
from concurrent.futures import Executor, ProcessPoolExecutor
from datetime import datetime, timezone
from functools import cache, partial
from multiprocessing import freeze_support
try:
from aiohttp import web
from multidict import MultiMapping
from .middlewares imp... | 337 | 10,443 |
black | src/blackd/client.py | .py | import aiohttp
from aiohttp.typedefs import StrOrURL
import black
_DEFAULT_HEADERS = {"Content-Type": "text/plain; charset=utf-8"}
class BlackDClient:
def __init__(
self,
url: StrOrURL = "http://localhost:9090",
line_length: int | None = None,
skip_source_first_line: bool = False... | 93 | 3,986 |
black | src/blib2to3/pygram.py | .py | # Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Export the Python grammar and symbols."""
# Python imports
import os
from typing import Union
# Local imports
from .pgen2 import driver
from .pgen2.grammar import Grammar
# Moved into initialize because mypyc can'... | 208 | 5,003 |
black | src/blib2to3/pytree.py | .py | # Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""
Python parse tree definitions.
This is a very concrete parse tree; we need to keep every token and
even the comments and whitespace between tokens.
There's also a pattern matching implementation here.
"""
# mypy:... | 1,074 | 37,184 |
black | src/blib2to3/pgen2/parse.py | .py | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Parser engine for the grammar tables generated by pgen.
The grammar table must be loaded first.
See Parser/parser.c in the Python distribution for additional info on
how this parsing engine works.
... | 396 | 15,478 |
black | src/blib2to3/pgen2/driver.py | .py | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
# Modifications:
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Parser driver.
This provides a high-level interface to parse a file into a synta... | 322 | 10,709 |
black | src/blib2to3/pgen2/grammar.py | .py | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""This module defines the data structures used to represent a grammar.
These are a bit arcane because they are derived from the data
structures used by Python's 'pgen' parser generator.
There's also ... | 229 | 6,846 |
black | src/blib2to3/pgen2/token.py | .py | """Token constants (from "token.h")."""
from typing import Final
# Taken from Python (r53757) and modified to include some tokens
# originally monkeypatched in by pgen2.tokenize
# --start constants--
ENDMARKER: Final = 0
NAME: Final = 1
NUMBER: Final = 2
STRING: Final = 3
NEWLINE: Final = 4
INDENT: Final = 5
DEDE... | 85 | 1,810 |
black | src/blib2to3/pgen2/literals.py | .py | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Safely evaluate Python string literals without using eval()."""
import re
simple_escapes: dict[str, str] = {
"a": "\a",
"b": "\b",
"f": "\f",
"n": "\n",
"r": "\r",
"t": "\t"... | 66 | 1,580 |
black | src/blib2to3/pgen2/__init__.py | .py | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""The pgen2 package."""
| 5 | 143 |
black | src/blib2to3/pgen2/tokenize.py | .py | # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation.
# All rights reserved.
# mypy: allow-untyped-defs, allow-untyped-calls
"""Tokenization help for Python programs.
generate_tokens(readline) is a generator that breaks a stream of
text into Python tokens. It accepts a readline-like method ... | 278 | 9,037 |
black | src/blib2to3/pgen2/conv.py | .py | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
# mypy: ignore-errors
"""Convert graminit.[ch] spit out by pgen to Python code.
Pgen is the Python parser generator. It is useful to quickly create a
parser from a grammar file in Python's grammar no... | 257 | 9,596 |
black | src/blib2to3/pgen2/pgen.py | .py | # Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
import os
from collections.abc import Iterator, Sequence
from typing import IO, Any, NoReturn, Union
from blib2to3.pgen2 import grammar, token, tokenize
from blib2to3.pgen2.tokenize import TokenInfo
P... | 389 | 14,131 |
coveragepy | igor.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Helper for building, testing, and linting coverage.py.
To get portability, all these operations are written in Python here instead
of in shell scripts, batch ... | 529 | 17,057 |
coveragepy | setup.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Code coverage measurement for Python"""
# Setuptools setup for coverage.py
# This file is used unchanged under all versions of Python.
import os
import os.pa... | 273 | 9,406 |
coveragepy | __main__.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Be able to execute coverage.py by pointing Python at a working tree."""
import os
import runpy
PKG = "coverage"
run_globals = runpy.run_module(PKG, run_name... | 13 | 423 |
coveragepy | tests/test_report.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Test text-based summary reporting for coverage.py"""
from __future__ import annotations
import glob
import io
import math
import os
import os.path
import py_... | 1,296 | 47,667 |
coveragepy | tests/test_report_core.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for helpers in report.py"""
from __future__ import annotations
from collections.abc import Iterable
from typing import IO
import pytest
from coverage... | 69 | 2,308 |
coveragepy | tests/test_api.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for coverage.py's API."""
from __future__ import annotations
import fnmatch
import glob
import io
import os
import os.path
import re
import shutil
impo... | 1,680 | 60,029 |
coveragepy | tests/test_core.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for core selection of coverage.py."""
from __future__ import annotations
import pytest
import coverage
from coverage import env
from coverage.exceptio... | 155 | 5,949 |
coveragepy | tests/test_concurrency.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for concurrency libraries."""
from __future__ import annotations
import glob
import multiprocessing
import os
import pathlib
import random
import re
im... | 822 | 27,226 |
coveragepy | tests/test_venv.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests about understanding how third-party code is installed."""
from __future__ import annotations
import os
import os.path
import shutil
from collections.ab... | 404 | 14,394 |
coveragepy | tests/test_bytecode.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for coverage.py's bytecode analysis."""
from __future__ import annotations
import dis
from textwrap import dedent
from coverage import env
from covera... | 45 | 1,422 |
coveragepy | tests/test_misc.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests of miscellaneous stuff."""
from __future__ import annotations
import sys
from typing import Any
from unittest import mock
import pytest
from coverage... | 213 | 6,970 |
coveragepy | tests/test_templite.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for coverage.templite."""
from __future__ import annotations
import re
from types import SimpleNamespace
from typing import Any, ContextManager
import... | 386 | 13,640 |
coveragepy | tests/test_phystokens.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for coverage.py's improved tokenizer."""
from __future__ import annotations
import os.path
import re
import sys
import textwrap
import warnings
import... | 302 | 10,258 |
coveragepy | tests/test_testing.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests that our test infrastructure is really working!"""
from __future__ import annotations
import datetime
import os
import re
import sys
import warnings
i... | 492 | 17,905 |
coveragepy | tests/test_process.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for process behavior of coverage.py."""
from __future__ import annotations
import csv
import glob
import itertools
import json
import os
import os.path... | 1,787 | 62,844 |
coveragepy | tests/plugin2.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""A file tracer plugin for test_plugins.py to import."""
from __future__ import annotations
import os.path
from types import FrameType
from typing import Any
... | 74 | 2,252 |
coveragepy | tests/test_oddball.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Oddball cases for testing coverage.py"""
from __future__ import annotations
import os.path
import re
import sys
import warnings
import pytest
import covera... | 785 | 26,949 |
coveragepy | tests/coveragetest.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Base test case class for coverage.py testing."""
from __future__ import annotations
import collections
import contextlib
import datetime
import glob
import i... | 523 | 19,994 |
coveragepy | tests/test_report_common.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests of behavior common to all reporting."""
from __future__ import annotations
import textwrap
import coverage
from coverage.files import abs_file
from te... | 302 | 10,483 |
coveragepy | tests/test_filereporter.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for FileReporters"""
from __future__ import annotations
import sys
from coverage.plugin import FileReporter
from coverage.python import PythonFileRepo... | 104 | 4,068 |
coveragepy | tests/test_debug.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests of coverage/debug.py"""
from __future__ import annotations
import ast
import io
import os
import re
import sys
from collections.abc import Callable, It... | 510 | 17,590 |
coveragepy | tests/strategies.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Hypothesis strategies for use in tests."""
from __future__ import annotations
from collections.abc import Sequence
from hypothesis import strategies as st
... | 98 | 3,255 |
coveragepy | tests/test_config.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Test the config file handling for coverage.py"""
from __future__ import annotations
import os
import tempfile
from pathlib import Path
from unittest import m... | 1,140 | 40,714 |
coveragepy | tests/goldtest.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""A test base class for tests based on gold file comparison."""
from __future__ import annotations
import difflib
import filecmp
import fnmatch
import os
impor... | 196 | 7,114 |
coveragepy | tests/test_version.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests of version.py."""
from __future__ import annotations
import coverage
from coverage.version import _make_version
from tests.coveragetest import Coverage... | 33 | 1,279 |
coveragepy | tests/__init__.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Automated tests. Run with pytest."""
| 5 | 198 |
coveragepy | tests/test_sqlitedb.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for coverage.sqlitedb"""
from __future__ import annotations
from unittest import mock
import pytest
from coverage.exceptions import DataError
from co... | 97 | 4,529 |
coveragepy | tests/test_setup.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests of miscellaneous stuff."""
from __future__ import annotations
import sys
from typing import cast
import pytest
import coverage
from coverage import e... | 61 | 2,042 |
coveragepy | tests/test_regions.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for coverage/regions.py."""
from __future__ import annotations
import collections
import textwrap
from pathlib import Path
import pytest
from coverag... | 113 | 4,053 |
coveragepy | tests/test_lcov.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Test LCOV-based summary reporting for coverage.py."""
from __future__ import annotations
import math
import os
import textwrap
import pytest
import coverag... | 764 | 22,385 |
coveragepy | tests/test_annotate.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for annotation from coverage.py."""
from __future__ import annotations
import coverage
from tests.coveragetest import CoverageTest
from tests.goldtest ... | 145 | 3,784 |
coveragepy | tests/test_numbits.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for coverage.numbits"""
from __future__ import annotations
import json
import sqlite3
from collections.abc import Iterable
from coverage import env
fr... | 195 | 6,357 |
coveragepy | tests/test_parser.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for coverage.py's code parsing."""
from __future__ import annotations
import ast
import re
import textwrap
import tokenize
from unittest import mock
i... | 1,491 | 45,812 |
coveragepy | tests/test_python.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests of coverage/python.py"""
from __future__ import annotations
import pathlib
import sys
import pytest
from coverage import env
from coverage.python imp... | 87 | 2,913 |
coveragepy | tests/test_mixins.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests of code in tests/mixins.py"""
from __future__ import annotations
import pytest
from coverage.misc import import_local_file
from tests.mixins import Re... | 86 | 3,022 |
coveragepy | tests/hypo.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""A Hypothesis wrapper so we can turn it off completely in environments it doesn't support."""
from __future__ import annotations
from typing import Any
impor... | 46 | 1,238 |
coveragepy | tests/test_coverage.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for coverage.py."""
from __future__ import annotations
import pytest
import coverage
from coverage import env
from coverage.exceptions import NoDataEr... | 1,889 | 47,246 |
coveragepy | tests/osinfo.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""OS information for testing."""
from __future__ import annotations
import sys
if sys.platform == "win32":
# Windows implementation
def process_ram() ... | 91 | 3,276 |
coveragepy | tests/test_collector.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests of coverage/collector.py and other collectors."""
from __future__ import annotations
import os.path
import coverage
from tests.coveragetest import Cov... | 58 | 1,697 |
coveragepy | tests/test_arcs.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for coverage.py's arc measurement."""
from __future__ import annotations
import textwrap
from unittest import mock
import pytest
import coverage
impo... | 2,419 | 66,028 |
coveragepy | tests/test_json.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Test json-based summary reporting for coverage.py"""
from __future__ import annotations
import json
import os
from datetime import datetime
from typing impor... | 565 | 17,934 |
coveragepy | tests/select_plugin.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""
A pytest plugin to select tests by running an external command.
See lab/pick.py for how to use pick.py to subset test suites.
More about this: https://nedba... | 36 | 1,221 |
coveragepy | tests/mixins.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""
Test class mixins
Some of these are transitional while working toward pure-pytest style.
"""
from __future__ import annotations
import importlib
import os
... | 150 | 5,042 |
coveragepy | tests/test_sysmon.py | .py | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
"""Tests for the sys.monitoring core in coverage/sysmon.py."""
from __future__ import annotations
from unittest import mock
import pytest
from coverage import... | 76 | 2,985 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.