Skip to content

Commit 6c1bd08

Browse files
saroad2cooperlees
andauthored
Test run black on self (#3114)
* Add run_self environment in tox * Add run_self task as part of the lint CI flow * Remove hard coded sources list * Remove black from pre-commit Co-authored-by: Cooper Lees <[email protected]>
1 parent 799adb5 commit 6c1bd08

File tree

4 files changed

+14
-56
lines changed

4 files changed

+14
-56
lines changed

.github/workflows/lint.yml

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ jobs:
2525
run: |
2626
python -m pip install --upgrade pip
2727
python -m pip install -e '.[d]'
28+
python -m pip install tox
2829
2930
- name: Lint
3031
uses: pre-commit/[email protected]
32+
33+
- name: Run On Self
34+
run: |
35+
tox -e run_self

.pre-commit-config.yaml

-8
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ exclude: ^(src/blib2to3/|profiling/|tests/data/)
44
repos:
55
- repo: local
66
hooks:
7-
- id: black
8-
name: black
9-
language: system
10-
entry: black
11-
minimum_pre_commit_version: 2.9.2
12-
require_serial: true
13-
types_or: [python, pyi]
14-
157
- id: check-pre-commit-rev-in-example
168
name: Check pre-commit rev in example
179
language: python

tests/test_format.py

+1-47
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import replace
2-
from typing import Any, Iterator, List
2+
from typing import Any, Iterator
33
from unittest.mock import patch
44

55
import pytest
@@ -14,47 +14,6 @@
1414
all_data_cases,
1515
)
1616

17-
SOURCES: List[str] = [
18-
"src/black/__init__.py",
19-
"src/black/__main__.py",
20-
"src/black/brackets.py",
21-
"src/black/cache.py",
22-
"src/black/comments.py",
23-
"src/black/concurrency.py",
24-
"src/black/const.py",
25-
"src/black/debug.py",
26-
"src/black/files.py",
27-
"src/black/linegen.py",
28-
"src/black/lines.py",
29-
"src/black/mode.py",
30-
"src/black/nodes.py",
31-
"src/black/numerics.py",
32-
"src/black/output.py",
33-
"src/black/parsing.py",
34-
"src/black/report.py",
35-
"src/black/rusty.py",
36-
"src/black/strings.py",
37-
"src/black/trans.py",
38-
"src/blackd/__init__.py",
39-
"src/blib2to3/pygram.py",
40-
"src/blib2to3/pytree.py",
41-
"src/blib2to3/pgen2/conv.py",
42-
"src/blib2to3/pgen2/driver.py",
43-
"src/blib2to3/pgen2/grammar.py",
44-
"src/blib2to3/pgen2/literals.py",
45-
"src/blib2to3/pgen2/parse.py",
46-
"src/blib2to3/pgen2/pgen.py",
47-
"src/blib2to3/pgen2/tokenize.py",
48-
"src/blib2to3/pgen2/token.py",
49-
"setup.py",
50-
"tests/test_black.py",
51-
"tests/test_blackd.py",
52-
"tests/test_format.py",
53-
"tests/optional.py",
54-
"tests/util.py",
55-
"tests/conftest.py",
56-
]
57-
5817

5918
@pytest.fixture(autouse=True)
6019
def patch_dump_to_file(request: Any) -> Iterator[None]:
@@ -93,11 +52,6 @@ def test_preview_minimum_python_310_format(filename: str) -> None:
9352
assert_format(source, expected, mode, minimum_version=(3, 10))
9453

9554

96-
@pytest.mark.parametrize("filename", SOURCES)
97-
def test_source_is_formatted(filename: str) -> None:
98-
check_file("", filename, DEFAULT_MODE, data=False)
99-
100-
10155
# =============== #
10256
# Complex cases
10357
# ============= #

tox.ini

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = {,ci-}py{36,37,38,39,310,py3},fuzz
2+
envlist = {,ci-}py{36,37,38,39,310,py3},fuzz,run_self
33

44
[testenv]
55
setenv = PYTHONPATH = {toxinidir}/src
@@ -61,3 +61,10 @@ commands =
6161
coverage erase
6262
coverage run fuzz.py
6363
coverage report
64+
65+
[testenv:run_self]
66+
setenv = PYTHONPATH = {toxinidir}/src
67+
skip_install = True
68+
commands =
69+
pip install -e .[d]
70+
black --check {toxinidir}/src {toxinidir}/tests {toxinidir}/setup.py

0 commit comments

Comments
 (0)