Skip to content

Update usage to reflect the recent addition of the pytest plugin #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2023
Merged
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
19 changes: 11 additions & 8 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,17 @@ To manually add `debug` to `__builtins__`, add the following to `sitecustomize.p
which is always imported.

```py
# add devtools `debug` function to builtins
import builtins
try:
from devtools import debug
except ImportError:
pass
else:
setattr(builtins, 'debug', debug)
import sys
# we don't install here for pytest as it breaks pytest, it is
# installed later by a pytest fixture
if not sys.argv[0].endswith('pytest'):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Command name might also be py.test

It's an old name and hence unlikely, but is still included when installing pytest so can be used.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This copies from the script we auto-install, I think this is a good start.

import builtins
try:
from devtools import debug
except ImportError:
pass
else:
setattr(builtins, 'debug', debug)
```

The `ImportError` exception is important since you'll want python to run fine even if *devtools* isn't installed.
Expand Down