Skip to content

Commit 56d5a5c

Browse files
committed
Use pytest as test runner.
1 parent ca956fe commit 56d5a5c

File tree

8 files changed

+19
-126
lines changed

8 files changed

+19
-126
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ jobs:
4040
- name: Run tests
4141
run: |
4242
python --version
43-
python -m node.tests.__init__
43+
pytest src/node/tests
4444
4545
- name: Run coverage
4646
run: |
47-
coverage run --source=src/node --omit=src/node/testing/profiling.py -m node.tests.__init__
47+
coverage run --source=src/node --omit=src/node/testing/profiling.py -m pytest src/node/tests
4848
coverage report --fail-under=100

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/.coverage
44
/.mxmake
55
/.ruff_cache
6+
/.venv
67
/dist/
78
/htmlcov/
89
/requirements-mxdev.txt
9-
/venv

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Changes
88
- Fix ``Node.treerepr`` if mapping raises an exception on ``__getitem__``.
99
[rnix]
1010

11+
- Use pytest as test runner.
12+
[rnix]
13+
1114

1215
1.2.2 (2024-05-30)
1316
------------------

Makefile

Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#: core.mxfiles
88
#: core.packages
99
#: qa.coverage
10-
#: qa.ruff
1110
#: qa.test
1211
#
1312
# SETTINGS (ALL CHANGES MADE BELOW SETTINGS WILL BE LOST)
@@ -46,8 +45,8 @@ EXTRA_PATH?=
4645
PRIMARY_PYTHON?=python3
4746

4847
# Minimum required Python version.
49-
# Default: 3.7
50-
PYTHON_MIN_VERSION?=3.7
48+
# Default: 3.9
49+
PYTHON_MIN_VERSION?=3.9
5150

5251
# Install packages using the given package installer method.
5352
# Supported are `pip` and `uv`. If uv is used, its global availability is
@@ -80,7 +79,7 @@ VENV_CREATE?=true
8079
# `VENV_CREATE` is false it is expected to point to an existing virtual
8180
# environment. If `VENV_ENABLED` is `false` it is ignored.
8281
# Default: .venv
83-
VENV_FOLDER?=venv
82+
VENV_FOLDER?=.venv
8483

8584
# mxdev to install in virtual environment.
8685
# Default: mxdev
@@ -90,12 +89,6 @@ MXDEV?=mxdev
9089
# Default: mxmake
9190
MXMAKE?=mxmake
9291

93-
## qa.ruff
94-
95-
# Source folder to scan for Python files to run ruff on.
96-
# Default: src
97-
RUFF_SRC?=src
98-
9992
## core.mxfiles
10093

10194
# The config file to use.
@@ -114,7 +107,7 @@ PACKAGES_ALLOW_PRERELEASES?=false
114107
# The command which gets executed. Defaults to the location the
115108
# :ref:`run-tests` template gets rendered to if configured.
116109
# Default: .mxmake/files/run-tests.sh
117-
TEST_COMMAND?=$(VENV_FOLDER)/bin/python -m node.tests.__init__
110+
TEST_COMMAND?=$(VENV_FOLDER)/bin/pytest src/node/tests
118111

119112
# Additional Python requirements for running tests to be
120113
# installed (via pip).
@@ -134,7 +127,7 @@ COVERAGE_COMMAND?=\
134127
$(VENV_FOLDER)/bin/coverage run \
135128
--source=src/node \
136129
--omit=src/node/testing/profiling.py \
137-
-m node.tests.__init__ \
130+
-m pytest src/node/tests \
138131
&& $(VENV_FOLDER)/bin/coverage report --fail-under=100
139132

140133
##############################################################################
@@ -175,6 +168,8 @@ $(SENTINEL): $(firstword $(MAKEFILE_LIST))
175168
# mxenv
176169
##############################################################################
177170

171+
export OS:=$(OS)
172+
178173
# Determine the executable path
179174
ifeq ("$(VENV_ENABLED)", "true")
180175
export VIRTUAL_ENV=$(abspath $(VENV_FOLDER))
@@ -249,41 +244,6 @@ INSTALL_TARGETS+=mxenv
249244
DIRTY_TARGETS+=mxenv-dirty
250245
CLEAN_TARGETS+=mxenv-clean
251246

252-
##############################################################################
253-
# ruff
254-
##############################################################################
255-
256-
RUFF_TARGET:=$(SENTINEL_FOLDER)/ruff.sentinel
257-
$(RUFF_TARGET): $(MXENV_TARGET)
258-
@echo "Install Ruff"
259-
@$(PYTHON_PACKAGE_COMMAND) install ruff
260-
@touch $(RUFF_TARGET)
261-
262-
.PHONY: ruff-check
263-
ruff-check: $(RUFF_TARGET)
264-
@echo "Run ruff check"
265-
@ruff check $(RUFF_SRC)
266-
267-
.PHONY: ruff-format
268-
ruff-format: $(RUFF_TARGET)
269-
@echo "Run ruff format"
270-
@ruff format $(RUFF_SRC)
271-
272-
.PHONY: ruff-dirty
273-
ruff-dirty:
274-
@rm -f $(RUFF_TARGET)
275-
276-
.PHONY: ruff-clean
277-
ruff-clean: ruff-dirty
278-
@test -e $(MXENV_PYTHON) && $(MXENV_PYTHON) -m pip uninstall -y ruff || :
279-
@rm -rf .ruff_cache
280-
281-
INSTALL_TARGETS+=$(RUFF_TARGET)
282-
CHECK_TARGETS+=ruff-check
283-
FORMAT_TARGETS+=ruff-format
284-
DIRTY_TARGETS+=ruff-dirty
285-
CLEAN_TARGETS+=ruff-clean
286-
287247
##############################################################################
288248
# mxfiles
289249
##############################################################################
@@ -442,6 +402,10 @@ INSTALL_TARGETS+=$(COVERAGE_TARGET)
442402
DIRTY_TARGETS+=coverage-dirty
443403
CLEAN_TARGETS+=coverage-clean
444404

405+
##############################################################################
406+
# Custom includes
407+
##############################################################################
408+
445409
-include $(INCLUDE_MAKEFILE)
446410

447411
##############################################################################

mx.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[settings]
2-
main-package = -e .
2+
main-package = -e .[test]

ruff.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ def read_file(name):
5454
'zope.deprecation',
5555
'zope.lifecycleevent'
5656
],
57-
test_suite='node.tests.test_suite'
57+
extras_require=dict(test=['pytest']),
5858
)

src/node/tests/__init__.py

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -71,73 +71,3 @@ def checkOutput(self, want, got, optionflags=None):
7171

7272
# B/C
7373
check_output = checkOutput
74-
75-
76-
def test_suite():
77-
from node.tests import test_adopt
78-
from node.tests import test_alias
79-
from node.tests import test_attributes
80-
from node.tests import test_base
81-
from node.tests import test_cache
82-
from node.tests import test_common
83-
from node.tests import test_constraints
84-
from node.tests import test_context
85-
from node.tests import test_events
86-
from node.tests import test_factories
87-
from node.tests import test_fallback
88-
from node.tests import test_filter
89-
from node.tests import test_lifecycle
90-
from node.tests import test_locking
91-
from node.tests import test_mapping
92-
from node.tests import test_node
93-
from node.tests import test_nodespace
94-
from node.tests import test_order
95-
from node.tests import test_reference
96-
from node.tests import test_schema
97-
from node.tests import test_sequence
98-
from node.tests import test_serializer
99-
from node.tests import test_storage
100-
from node.tests import test_testing
101-
from node.tests import test_tests
102-
from node.tests import test_utils
103-
104-
suite = unittest.TestSuite()
105-
106-
suite.addTest(unittest.findTestCases(test_testing))
107-
suite.addTest(unittest.findTestCases(test_tests))
108-
109-
suite.addTest(unittest.findTestCases(test_base))
110-
suite.addTest(unittest.findTestCases(test_events))
111-
suite.addTest(unittest.findTestCases(test_locking))
112-
suite.addTest(unittest.findTestCases(test_schema))
113-
suite.addTest(unittest.findTestCases(test_serializer))
114-
suite.addTest(unittest.findTestCases(test_utils))
115-
116-
suite.addTest(unittest.findTestCases(test_adopt))
117-
suite.addTest(unittest.findTestCases(test_alias))
118-
suite.addTest(unittest.findTestCases(test_attributes))
119-
suite.addTest(unittest.findTestCases(test_cache))
120-
suite.addTest(unittest.findTestCases(test_common))
121-
suite.addTest(unittest.findTestCases(test_constraints))
122-
suite.addTest(unittest.findTestCases(test_context))
123-
suite.addTest(unittest.findTestCases(test_factories))
124-
suite.addTest(unittest.findTestCases(test_fallback))
125-
suite.addTest(unittest.findTestCases(test_filter))
126-
suite.addTest(unittest.findTestCases(test_lifecycle))
127-
suite.addTest(unittest.findTestCases(test_mapping))
128-
suite.addTest(unittest.findTestCases(test_node))
129-
suite.addTest(unittest.findTestCases(test_nodespace))
130-
suite.addTest(unittest.findTestCases(test_order))
131-
suite.addTest(unittest.findTestCases(test_reference))
132-
suite.addTest(unittest.findTestCases(test_sequence))
133-
suite.addTest(unittest.findTestCases(test_storage))
134-
135-
return suite
136-
137-
138-
if __name__ == '__main__':
139-
import sys
140-
141-
runner = unittest.TextTestRunner(failfast=True)
142-
result = runner.run(test_suite())
143-
sys.exit(not result.wasSuccessful())

0 commit comments

Comments
 (0)