-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move doctest setup routines to a location actually checked by pytest
- Loading branch information
Sebastian Böck
committed
Nov 12, 2018
1 parent
2ce69a6
commit e01ed43
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
# set and restore numpy's print options for doctests | ||
_NP_PRINT_OPTIONS = np.get_printoptions() | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def setup_package(request): | ||
"""Set up the environment for doctests (when run through pytest).""" | ||
np.set_printoptions(precision=5, edgeitems=2, suppress=True) | ||
|
||
def fin(): | ||
"""Restore the environment after doctests (when run through pytest).""" | ||
np.set_printoptions(**_NP_PRINT_OPTIONS) | ||
|
||
request.addfinalizer(fin) |