|
1 | 1 | from __future__ import print_function
|
2 | 2 |
|
3 |
| -from functools import wraps |
4 | 3 | import os
|
5 | 4 | import sys
|
6 | 5 | import collections
|
|
16 | 15 | import base64
|
17 | 16 |
|
18 | 17 | from future.moves.urllib.parse import urlparse
|
19 |
| -from _pytest.assertion.rewrite import AssertionRewritingHook |
20 | 18 |
|
21 | 19 | import flask
|
22 | 20 | from flask_compress import Compress
|
@@ -1708,13 +1706,18 @@ def enable_dev_tools(
|
1708 | 1706 |
|
1709 | 1707 | # # additional condition to account for AssertionRewritingHook object
|
1710 | 1708 | # # loader when running pytest
|
1711 |
| - for index, package in enumerate(packages): |
1712 |
| - if isinstance(package, AssertionRewritingHook): |
1713 |
| - print("YES") |
1714 |
| - dash_spec = importlib.util.find_spec("dash") |
1715 |
| - dash_test_path = dash_spec.submodule_search_locations[0] |
1716 |
| - setattr(dash_spec, "path", dash_test_path) |
1717 |
| - packages[index] = dash_spec |
| 1709 | + |
| 1710 | + if "_pytest" in sys.modules: |
| 1711 | + from _pytest.assertion.rewrite import ( # pylint: disable=import-outside-toplevel |
| 1712 | + AssertionRewritingHook, |
| 1713 | + ) |
| 1714 | + |
| 1715 | + for index, package in enumerate(packages): |
| 1716 | + if isinstance(package, AssertionRewritingHook): |
| 1717 | + dash_spec = importlib.util.find_spec("dash") |
| 1718 | + dash_test_path = dash_spec.submodule_search_locations[0] |
| 1719 | + setattr(dash_spec, "path", dash_test_path) |
| 1720 | + packages[index] = dash_spec |
1718 | 1721 |
|
1719 | 1722 | component_packages_dist = [
|
1720 | 1723 | dash_test_path
|
|
0 commit comments