Skip to content

Commit 2afc3ad

Browse files
willkggsnedders
authored andcommitted
Fail hard with tracebacks if pytest-expect isn't working (#360)
Fixes #329
1 parent 85bc5fa commit 2afc3ad

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

html5lib/tests/conftest.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
from __future__ import print_function
12
import os.path
3+
import sys
24

35
import pkg_resources
46
import pytest
@@ -15,6 +17,26 @@
1517
_sanitizer_testdata = os.path.join(_dir, "sanitizer-testdata")
1618

1719

20+
def fail_if_missing_pytest_expect():
21+
"""Throws an exception halting pytest if pytest-expect isn't working"""
22+
try:
23+
from pytest_expect import expect # noqa
24+
except ImportError:
25+
header = '*' * 78
26+
print(
27+
'\n' +
28+
header + '\n' +
29+
'ERROR: Either pytest-expect or its dependency u-msgpack-python is not\n' +
30+
'installed. Please install them both before running pytest.\n' +
31+
header + '\n',
32+
file=sys.stderr
33+
)
34+
raise
35+
36+
37+
fail_if_missing_pytest_expect()
38+
39+
1840
def pytest_configure(config):
1941
msgs = []
2042

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy