Skip to content

Commit 04383b2

Browse files
committed
try/except for pytest exit code import
1 parent 1397af8 commit 04383b2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

nbval/nbdime_reporter.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,18 @@
77

88
# import the pytest API
99
import pytest
10-
from _pytest.main import EXIT_OK, EXIT_TESTSFAILED, EXIT_INTERRUPTED, \
11-
EXIT_USAGEERROR, EXIT_NOTESTSCOLLECTED
10+
try:
11+
from _pytest.main import ExitCode
12+
EXIT_OK = ExitCode.OK
13+
EXIT_TESTSFAILED = ExitCode.TESTS_FAILED
14+
EXIT_INTERRUPTED = ExitCode.INTERRUPTED
15+
EXIT_USAGEERROR = ExitCode.USAGE_ERROR
16+
EXIT_NOTESTSCOLLECTED = ExitCode.NO_TESTS_COLLECTED
17+
except ImportError:
18+
# pytest < 0.5.0
19+
from _pytest.main import EXIT_OK, EXIT_TESTSFAILED, EXIT_INTERRUPTED, \
20+
EXIT_USAGEERROR, EXIT_NOTESTSCOLLECTED
21+
1222

1323
import re
1424
import copy

0 commit comments

Comments
 (0)