Skip to content

Commit

Permalink
Pytest 8.1 fix (#120)
Browse files Browse the repository at this point in the history
* fix for pytest 8.1
* add vm devcontainer
* devcontainer and docs
  • Loading branch information
alex-treebeard authored Mar 4, 2024
1 parent ed2b59b commit bb4706c
Show file tree
Hide file tree
Showing 12 changed files with 304 additions and 232 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Python 3",
"name": "Codespaces Devcontainer",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
Expand Down
11 changes: 11 additions & 0 deletions .devcontainer/vm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.148.1/containers/python-3/.devcontainer/base.Dockerfile
ARG VARIANT="3.11"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
ARG INSTALL_NODE="true"
ARG NODE_VERSION="lts/*"
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
USER vscode
RUN pip3 --disable-pip-version-check --no-cache-dir install -U \
'poetry==1.1.13' \
'pip==22.1.2'
RUN npm install -g @devcontainers/[email protected]
39 changes: 39 additions & 0 deletions .devcontainer/vm/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "VM Devcontainer",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"VARIANT": "3.10",
"INSTALL_NODE": "true",
"NODE_VERSION": "18.7"
}
},
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh",
"python.pythonPath": "/usr/local/bin/python"
},
"extensions": [
"ms-python.python"
]
}
},
"features": {
"ghcr.io/devcontainers-contrib/features/starship-homebrew:1": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {
},
},
"mounts": [
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.zsh_history,target=/home/vscode/.zsh_history,type=bind,consistency=cached",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.zshrc,target=/home/vscode/.zshrc,type=bind,consistency=cached",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.zshenv,target=/home/vscode/.zshenv,type=bind,consistency=cached",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.config/starship.toml,target=/home/vscode/.config/starship.toml,type=bind,consistency=cached",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.config/gh,target=/home/vscode/.config/gh,type=bind,consistency=cached",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,consistency=cached",
],
"remoteUser": "vscode"
}
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ assignees: ''

---

> [!Note]
> It may be quicker to check in with us on [Discord](https://discord.gg/QFjCpMjqRY) before logging your issue


**Describe the bug**
A clear and concise description of what the bug is.

Expand Down
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ assignees: ''

---

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

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ For non-vscode users, here are some install steps:

### Install local package
```
poetry install # warning, by default this will install without a venv unless you modify poetry.toml
poetry install
```

### Activate shell
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ pytest -p no:nbmake

## ℹ️ Get help with machine learning infrastructure

Beyond testing notebooks, the maintainers of nbmake help software and finance companies scale their machine learning products.

[Find out more](https://www.treebeard.io/).
Join our [Discord](https://discord.gg/QFjCpMjqRY) for support and learning through the community.

---
435 changes: 220 additions & 215 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Pygments = "^2.7.3"
ipykernel = ">=5.4.0"

[tool.poetry.dev-dependencies]
pytest = "^7.1.0"
pytest = "^8.1.0"
pre-commit = "^2.8.2"
pytest-cov = "^2.10.1"
pytest-xdist = "^2.1.0"
Expand Down
3 changes: 1 addition & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[pytest]
testpaths =
tests
timeout = 180
tests
27 changes: 18 additions & 9 deletions src/nbmake/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,28 @@ def pytest_addoption(parser: Any):
)


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

if ver < 7:

ver: int = int(version("pytest")[0])
if ver < 7:

def pytest_collect_file(path: str, parent: Any) -> Optional[Any]:
if _should_collect(Path(path), parent.config.option.nbmake):
return NotebookFile.from_parent(parent, fspath=path)

return NotebookFile.from_parent(parent, path=p)
else:

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


def pytest_terminal_summary(terminalreporter: Any, exitstatus: int, config: Any):
pass
if config.option.nbmake:
# this message can be disabled with pytest --no-summary
# but let us know if it is annoying you
# ...we can also print diagnostics/stats here -- requests welcome
discord = "https://discord.gg/QFjCpMjqRY"
print(f"\n📝 nbmake support is available in discord: {discord}\n")
3 changes: 3 additions & 0 deletions tests/resources/a_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

def test_x():
assert True

0 comments on commit bb4706c

Please sign in to comment.