Skip to content

Commit bb4706c

Browse files
Pytest 8.1 fix (#120)
* fix for pytest 8.1 * add vm devcontainer * devcontainer and docs
1 parent ed2b59b commit bb4706c

File tree

12 files changed

+304
-232
lines changed

12 files changed

+304
-232
lines changed

.devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Python 3",
2+
"name": "Codespaces Devcontainer",
33
"build": {
44
"dockerfile": "Dockerfile",
55
"context": "..",

.devcontainer/vm/Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.148.1/containers/python-3/.devcontainer/base.Dockerfile
2+
ARG VARIANT="3.11"
3+
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
4+
ARG INSTALL_NODE="true"
5+
ARG NODE_VERSION="lts/*"
6+
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
7+
USER vscode
8+
RUN pip3 --disable-pip-version-check --no-cache-dir install -U \
9+
'poetry==1.1.13' \
10+
'pip==22.1.2'
11+
RUN npm install -g @devcontainers/[email protected]

.devcontainer/vm/devcontainer.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "VM Devcontainer",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": "..",
6+
"args": {
7+
"VARIANT": "3.10",
8+
"INSTALL_NODE": "true",
9+
"NODE_VERSION": "18.7"
10+
}
11+
},
12+
"customizations": {
13+
"vscode": {
14+
"settings": {
15+
"terminal.integrated.defaultProfile.linux": "zsh",
16+
"python.pythonPath": "/usr/local/bin/python"
17+
},
18+
"extensions": [
19+
"ms-python.python"
20+
]
21+
}
22+
},
23+
"features": {
24+
"ghcr.io/devcontainers-contrib/features/starship-homebrew:1": {},
25+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
26+
"ghcr.io/devcontainers/features/github-cli:1": {
27+
},
28+
},
29+
"mounts": [
30+
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached",
31+
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.zsh_history,target=/home/vscode/.zsh_history,type=bind,consistency=cached",
32+
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.zshrc,target=/home/vscode/.zshrc,type=bind,consistency=cached",
33+
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.zshenv,target=/home/vscode/.zshenv,type=bind,consistency=cached",
34+
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.config/starship.toml,target=/home/vscode/.config/starship.toml,type=bind,consistency=cached",
35+
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.config/gh,target=/home/vscode/.config/gh,type=bind,consistency=cached",
36+
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,consistency=cached",
37+
],
38+
"remoteUser": "vscode"
39+
}

.github/ISSUE_TEMPLATE/bug_report.md

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ assignees: ''
77

88
---
99

10+
> [!Note]
11+
> It may be quicker to check in with us on [Discord](https://discord.gg/QFjCpMjqRY) before logging your issue
12+
13+
14+
1015
**Describe the bug**
1116
A clear and concise description of what the bug is.
1217

.github/ISSUE_TEMPLATE/feature_request.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ assignees: ''
77

88
---
99

10+
> [!Note]
11+
> It may be quicker to check in with us on [Discord](https://discord.gg/QFjCpMjqRY) before logging your issue
12+
1013
**Is your feature request related to a problem? Please describe.**
1114
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
1215

CONTRIBUTING.MD

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ For non-vscode users, here are some install steps:
77

88
### Install local package
99
```
10-
poetry install # warning, by default this will install without a venv unless you modify poetry.toml
10+
poetry install
1111
```
1212

1313
### Activate shell

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ pytest -p no:nbmake
250250

251251
## ℹ️ Get help with machine learning infrastructure
252252

253-
Beyond testing notebooks, the maintainers of nbmake help software and finance companies scale their machine learning products.
254-
255-
[Find out more](https://www.treebeard.io/).
253+
Join our [Discord](https://discord.gg/QFjCpMjqRY) for support and learning through the community.
256254

257255
---

poetry.lock

+220-215
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Pygments = "^2.7.3"
2222
ipykernel = ">=5.4.0"
2323

2424
[tool.poetry.dev-dependencies]
25-
pytest = "^7.1.0"
25+
pytest = "^8.1.0"
2626
pre-commit = "^2.8.2"
2727
pytest-cov = "^2.10.1"
2828
pytest-xdist = "^2.1.0"

pytest.ini

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
[pytest]
22
testpaths =
3-
tests
4-
timeout = 180
3+
tests

src/nbmake/pytest_plugin.py

+18-9
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,28 @@ def pytest_addoption(parser: Any):
5050
)
5151

5252

53-
def pytest_collect_file(path: str, parent: Any) -> Optional[Any]:
54-
opt = parent.config.option
55-
p = Path(path)
56-
if opt.nbmake and p.match("*ipynb") and "_build" not in p.parts:
57-
ver: int = int(version("pytest")[0])
53+
def _should_collect(p: Path, nbmake_enabled: bool):
54+
return nbmake_enabled and p.match("*ipynb") and "_build" not in p.parts
5855

59-
if ver < 7:
56+
57+
ver: int = int(version("pytest")[0])
58+
if ver < 7:
59+
60+
def pytest_collect_file(path: str, parent: Any) -> Optional[Any]:
61+
if _should_collect(Path(path), parent.config.option.nbmake):
6062
return NotebookFile.from_parent(parent, fspath=path)
6163

62-
return NotebookFile.from_parent(parent, path=p)
64+
else:
6365

64-
return None
66+
def pytest_collect_file(file_path: Path, parent: Any) -> Optional[Any]:
67+
if _should_collect(file_path, parent.config.option.nbmake):
68+
return NotebookFile.from_parent(parent, path=file_path)
6569

6670

6771
def pytest_terminal_summary(terminalreporter: Any, exitstatus: int, config: Any):
68-
pass
72+
if config.option.nbmake:
73+
# this message can be disabled with pytest --no-summary
74+
# but let us know if it is annoying you
75+
# ...we can also print diagnostics/stats here -- requests welcome
76+
discord = "https://discord.gg/QFjCpMjqRY"
77+
print(f"\n📝 nbmake support is available in discord: {discord}\n")

tests/resources/a_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
def test_x():
3+
assert True

0 commit comments

Comments
 (0)