ffmpeg-6: fix COMPONENT_REVISION
[oi-userland.git] / components / python / pytest-black / patches / 02-pytest-7.patch
blobb653c4779ed5026c0ca71d3da4b51944febd3d06
1 https://github.com/shopkeep/pytest-black/pull/61
3 diff --git a/.travis.yml b/.travis.yml
4 index d9891e3..178b5f6 100644
5 --- a/.travis.yml
6 +++ b/.travis.yml
7 @@ -1,6 +1,10 @@
8 language: python
9 matrix:
10 include:
11 + - python: 3.10
12 + env: TOX_ENV=py310,flake8
13 + - python: 3.9
14 + env: TOX_ENV=py39
15 - python: 3.8
16 env: TOX_ENV=py38
17 - python: 3.7
18 @@ -9,8 +13,6 @@ matrix:
19 env: TOX_ENV=py36
20 - python: 3.5
21 env: TOX_ENV=py35
22 - - python: 2.7
23 - env: TOX_ENV=py27
24 install:
25 - pip install tox
26 script:
27 diff --git a/pytest_black.py b/pytest_black.py
28 index 04c80cb..23b461f 100644
29 --- a/pytest_black.py
30 +++ b/pytest_black.py
31 @@ -20,13 +20,10 @@ def pytest_addoption(parser):
35 -def pytest_collect_file(path, parent):
36 +def pytest_collect_file(file_path, path, parent):
37 config = parent.config
38 if config.option.black and path.ext == ".py":
39 - if hasattr(BlackItem, "from_parent"):
40 - return BlackItem.from_parent(parent, fspath=path)
41 - else:
42 - return BlackItem(path, parent)
43 + return BlackFile.from_parent(parent, path=file_path)
46 def pytest_configure(config):
47 @@ -42,10 +39,17 @@ def pytest_unconfigure(config):
48 config.cache.set(HISTKEY, config._blackmtimes)
51 -class BlackItem(pytest.Item, pytest.File):
52 - def __init__(self, fspath, parent):
53 - super(BlackItem, self).__init__(fspath, parent)
54 - self._nodeid += "::BLACK"
55 +class BlackFile(pytest.File):
56 + def collect(self):
57 + """ returns a list of children (items and collectors)
58 + for this collection node.
59 + """
60 + yield BlackItem.from_parent(self, name="black")
63 +class BlackItem(pytest.Item):
64 + def __init__(self, **kwargs):
65 + super(BlackItem, self).__init__(**kwargs)
66 self.add_marker("black")
67 try:
68 with open("pyproject.toml") as toml_file:
69 @@ -61,8 +65,8 @@ def __init__(self, fspath, parent):
70 def setup(self):
71 pytest.importorskip("black")
72 mtimes = getattr(self.config, "_blackmtimes", {})
73 - self._blackmtime = self.fspath.mtime()
74 - old = mtimes.get(str(self.fspath), 0)
75 + self._blackmtime = self.path.stat().st_mtime
76 + old = mtimes.get(str(self.path), 0)
77 if self._blackmtime == old:
78 pytest.skip("file(s) previously passed black format checks")
80 @@ -70,7 +74,7 @@ def setup(self):
81 pytest.skip("file(s) excluded by pyproject.toml")
83 def runtest(self):
84 - cmd = [sys.executable, "-m", "black", "--check", "--diff", "--quiet", str(self.fspath)]
85 + cmd = [sys.executable, "-m", "black", "--check", "--diff", "--quiet", str(self.path)]
86 try:
87 subprocess.run(
88 cmd, check=True, stdout=subprocess.PIPE, universal_newlines=True
89 @@ -79,7 +83,7 @@ def runtest(self):
90 raise BlackError(e)
92 mtimes = getattr(self.config, "_blackmtimes", {})
93 - mtimes[str(self.fspath)] = self._blackmtime
94 + mtimes[str(self.path)] = self._blackmtime
96 def repr_failure(self, excinfo):
97 if excinfo.errisinstance(BlackError):
98 @@ -87,7 +91,7 @@ def repr_failure(self, excinfo):
99 return super(BlackItem, self).repr_failure(excinfo)
101 def reportinfo(self):
102 - return (self.fspath, -1, "Black format check")
103 + return (self.path, -1, "Black format check")
105 def _skip_test(self):
106 return self._excluded() or (not self._included())
107 @@ -95,24 +99,18 @@ def _skip_test(self):
108 def _included(self):
109 if "include" not in self.pyproject:
110 return True
111 - return re.search(self.pyproject["include"], str(self.fspath))
112 + return re.search(self.pyproject["include"], str(self.path))
114 def _excluded(self):
115 if "exclude" not in self.pyproject:
116 return False
117 - return re.search(self.pyproject["exclude"], str(self.fspath))
118 + return re.search(self.pyproject["exclude"], str(self.path))
120 def _re_fix_verbose(self, regex):
121 if "\n" in regex:
122 regex = "(?x)" + regex
123 return re.compile(regex)
125 - def collect(self):
126 - """ returns a list of children (items and collectors)
127 - for this collection node.
128 - """
129 - return (self,)
132 class BlackError(Exception):
133 pass
134 diff --git a/setup.py b/setup.py
135 index 88784dd..576a9f7 100644
136 --- a/setup.py
137 +++ b/setup.py
138 @@ -23,9 +23,9 @@ def read(fname):
139 long_description=read("README.md"),
140 long_description_content_type="text/markdown",
141 py_modules=["pytest_black"],
142 - python_requires=">=2.7",
143 + python_requires=">=3.5",
144 install_requires=[
145 - "pytest>=3.5.0",
146 + "pytest>=7.0.0",
147 # Minimum requirement on black 19.3b0 or later is not declared here as
148 # workaround for https://github.com/pypa/pipenv/issues/3928
149 'black; python_version >= "3.6"',
150 @@ -38,7 +38,6 @@ def read(fname):
151 "Framework :: Pytest",
152 "Intended Audience :: Developers",
153 "Topic :: Software Development :: Testing",
154 - "Programming Language :: Python :: 2.7",
155 "Programming Language :: Python :: 3",
156 "Operating System :: OS Independent",
157 "License :: OSI Approved :: MIT License",
158 diff --git a/tox.ini b/tox.ini
159 index 06711c2..0134ae4 100644
160 --- a/tox.ini
161 +++ b/tox.ini
162 @@ -3,10 +3,10 @@
163 ignore = E501
165 [tox]
166 -envlist = py27,py35,py36,py37,py38,flake8
167 +envlist = py35,py36,py37,py38,py39,py310,flake8
169 [testenv]
170 -deps = pytest>=3.0
171 +deps = pytest>=7.0
172 commands = pytest {posargs:tests}
174 [testenv:flake8]