Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks.git
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.33.0
rev: 0.36.1
hooks:
- id: check-github-workflows
- id: check-dependabot
- id: check-readthedocs
- repo: https://github.com/psf/black
rev: 25.1.0
rev: 26.1.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/PyCQA/isort
rev: 6.0.1
rev: 7.0.0
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
rev: v3.21.2
hooks:
- id: pyupgrade
args: ["--py37-plus"]
- repo: https://github.com/PyCQA/flake8
rev: 7.2.0
rev: 7.3.0
hooks:
- id: flake8
additional_dependencies:
- 'flake8-bugbear==24.12.12'
- 'flake8-comprehensions==3.16.0'
- 'flake8-typing-as-t==1.0.0'
- 'flake8-bugbear==25.11.29'
- 'flake8-comprehensions==3.17.0'
- 'flake8-typing-as-t==1.1.0'
- repo: https://github.com/sirosen/slyp
rev: 0.8.2
hooks:
Expand All @@ -49,7 +49,8 @@ repos:
- "-L"
- "assertIn"
- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.5.1
rev: v2.16.0
hooks:
- id: pyproject-fmt
args: ["--max-supported-python", "3.13"]
additional_dependencies: ["tox>=4.9"]
4 changes: 2 additions & 2 deletions nose2/plugins/loader/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def _method(self, method=method, argSet=argSet):
return method(self, *argSet)

_method = functools.update_wrapper(_method, method)
delattr(_method, "paramList")
del _method.paramList
setattr(testCaseClass, method_name, _method)
names.append(method_name)
return names
Expand All @@ -188,7 +188,7 @@ def func(argSet=argSet, obj=obj):
return obj(*argSet)

func = functools.update_wrapper(func, obj)
delattr(func, "paramList")
del func.paramList
name = f"{obj.__module__}.{obj.__name__}"
func_name = util.name_from_args(name, index, argSet)
yield util.transplant_class(ParamsFunctionCase, obj.__module__)(
Expand Down
6 changes: 3 additions & 3 deletions nose2/plugins/prettyassert.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ def _get_inspection_info(trace):
- statement which failed (which can be garbage -- don't trust it)
- can_tokenize: a bool indicating that the lines of source can be parsed
"""
(frame, fname, lineno, funcname, context, ctx_index) = inspect.getinnerframes(
trace
)[-1]
frame, fname, lineno, funcname, context, ctx_index = inspect.getinnerframes(trace)[
-1
]
original_source_lines, firstlineno = inspect.getsourcelines(frame)

# truncate to the code in this frame to remove anything after current
Expand Down
2 changes: 1 addition & 1 deletion nose2/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def tearDownTest(self, test):

event = events.StopLayerTeardownTestEvent(self.layer, test)
self.session.hooks.stopLayerTeardownTest(event)
delattr(test, "_layer_wasSetUp")
del test._layer_wasSetUp

def tearDown(self):
if self.layer is None:
Expand Down
4 changes: 2 additions & 2 deletions nose2/tests/functional/support/such/test_such.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ def test_setup(case):

@it.has_test_teardown
def test_teardown(case):
delattr(it, "is_funny")
delattr(case, "is_funny")
del it.is_funny
del case.is_funny

@it.should("do something else") # type: ignore[no-redef]
def test(case): # noqa: F811
Expand Down
8 changes: 3 additions & 5 deletions nose2/tests/functional/support/toml/a/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[tool.nose2.a]
a = 1

[tool.nose2.unittest]
plugins = "plugin_a"
[tool.nose2]
a.a = 1
unittest.plugins = "plugin_a"
4 changes: 2 additions & 2 deletions nose2/tests/functional/support/toml/b/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.nose2.b]
b = """
[tool.nose2]
b.b = """
4
5
"""
6 changes: 2 additions & 4 deletions nose2/tests/functional/test_collect_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ def test_collect_tests_in_package(self):


# expectations
EXPECT_LAYOUT1 = re.compile(
r"""Ran 25 tests in \d.\d+s
EXPECT_LAYOUT1 = re.compile(r"""Ran 25 tests in \d.\d+s

OK"""
)
OK""")
20 changes: 8 additions & 12 deletions nose2/tests/functional/test_mp_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,20 @@ def test_flatten_respects_class_fixtures(self):

def test_conn_prep(self):
self.plugin.bind_host = None
(parent_conn, child_conn) = self.plugin._prepConns()
(parent_pipe, child_pipe) = multiprocessing.Pipe()
parent_conn, child_conn = self.plugin._prepConns()
parent_pipe, child_pipe = multiprocessing.Pipe()
self.assertIsInstance(parent_conn, type(parent_pipe))
self.assertIsInstance(child_conn, type(child_pipe))

self.plugin.bind_host = "127.0.0.1"
self.plugin.bind_port = 0
(parent_conn, child_conn) = self.plugin._prepConns()
parent_conn, child_conn = self.plugin._prepConns()
self.assertIsInstance(parent_conn, connection.Listener)
self.assertIsInstance(child_conn, tuple)
self.assertEqual(parent_conn.address, child_conn[:2])

def test_conn_accept(self):
(parent_conn, child_conn) = multiprocessing.Pipe()
parent_conn, child_conn = multiprocessing.Pipe()
self.assertEqual(self.plugin._acceptConns(parent_conn), parent_conn)

listener = connection.Listener(("127.0.0.1", 0))
Expand Down Expand Up @@ -161,27 +161,23 @@ def test_dispatch_tests_receive_events(self):
{
"outcome": "failed",
"expected": False,
"metadata": {
"stdout": """\
"metadata": {"stdout": """\
-------------------- >> begin captured stdout << ---------------------
Hello stdout

--------------------- >> end captured stdout << ----------------------"""
},
--------------------- >> end captured stdout << ----------------------"""},
},
),
(
"testOutcome",
{
"outcome": "failed",
"expected": False,
"metadata": {
"stdout": """\
"metadata": {"stdout": """\
-------------------- >> begin captured stdout << ---------------------
Hello stdout

--------------------- >> end captured stdout << ----------------------"""
},
--------------------- >> end captured stdout << ----------------------"""},
},
),
("stopTest", {}),
Expand Down
8 changes: 2 additions & 6 deletions nose2/tests/unit/test_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ class TestCollector(TestCase):

def test_collector_completes_with_no_tests(self):
with open("unittest.cfg", "w") as ut_file:
ut_file.write(
dedent(
"""
ut_file.write(dedent("""
[unittest]
quiet = true
"""
)
)
"""))
test = collector.collector()
with RedirectStdStreams() as redir:
self.assertRaises(SystemExit, test.run, None)
Expand Down
6 changes: 2 additions & 4 deletions nose2/tests/unit/test_doctest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,13 @@ def test_handle_file_python_setup_py(self):
# The file should be ignored by the plugin as it cannot safely be
# imported.

setup_py = dedent(
"""\
setup_py = dedent("""\
'''
>>> never executed
'''
from setuptools import setup
setup(name='foo')
"""
)
""")
event = self._handle_file("setup.py", setup_py)
self.assertEqual(event.extraTests, [])

Expand Down
2 changes: 1 addition & 1 deletion nose2/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def object_from_name(name, module=None):
import_error = None
parts = name.split(".")
if module is None:
(module, import_error) = try_import_module_from_name(parts[:])
module, import_error = try_import_module_from_name(parts[:])
parts = parts[1:]
parent = None
obj = module
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ classifiers = [
dynamic = [
"version",
]
optional-dependencies.coverage_plugin = [
optional-dependencies.coverage-plugin = [
"coverage",
]
optional-dependencies.dev = [
Expand All @@ -54,8 +54,8 @@ urls.documentation = "https://docs.nose2.io/"
urls.repository = "https://github.com/nose-devs/nose2"
scripts.nose2 = "nose2:discover"

[tool.setuptools.dynamic]
version = { attr = "nose2.__version__" }
[tool.setuptools]
dynamic.version = { attr = "nose2.__version__" }

[tool.isort]
profile = "black"
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ commands =
!nocov: coverage report

[testenv:lint]
deps = pre-commit~=2.9.3
deps = pre-commit~=4.4.0
skip_install = true
commands = pre-commit run --all-files

Expand Down