Skip to content

Commit 584d52c

Browse files
committed
test: modernize how pytest collects demos
1 parent 5165b50 commit 584d52c

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ docs = [
4444
'Continuous Integration' = 'https://github.com/kxgames/glooey/actions'
4545
'Test Coverage' = 'https://coveralls.io/github/kxgames/glooey'
4646

47+
[tool.pytest.ini_options]
48+
norecursedirs = ".* .git *.egg assets __pycache__"
49+
4750
[tool.semantic_release]
4851
version_variable = 'glooey/__init__.py:__version__'
4952
build_command = 'python -m pip install flit && flit build'

tests/conftest.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ def pytest_addoption(parser):
99
def pytest_collect_file(path, parent):
1010
if parent.config.option.run_demos:
1111
if path.fnmatch('demo_*.py'):
12-
return DemoFile(path, parent)
12+
return DemoFile.from_parent(parent, fspath=path)
1313

1414
class DemoFile(pytest.File):
1515

1616
def collect(self):
1717
name = self.fspath.basename[:-len('.py')]
18-
yield DemoItem(name, self, self.fspath)
18+
yield DemoItem.from_parent(self, name=name, fspath=self.fspath)
1919

2020
class DemoItem(pytest.Item):
2121

22-
def __init__(self, name, parent, path):
22+
def __init__(self, name, parent, fspath):
2323
super().__init__(name, parent)
24-
self.path = path
24+
self.path = fspath
2525

2626
def runtest(self):
2727
run_demo(self.path.strpath)

tests/pytest.ini

-3
This file was deleted.

0 commit comments

Comments
 (0)