Skip to content

Commit b155722

Browse files
committed
Update skipif logic
1 parent f236624 commit b155722

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/test_documentation_build.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
"""Tests for documentation build."""
22

33
import os
4-
import sys
54

65
import pytest
76

87
try:
9-
import mkdocs # noqa: F401
10-
except ImportError:
11-
...
8+
import mkdocs
9+
# Even if 'mkdocs' is installed
10+
# 'mkdocs' is could be imported as <module 'mkdocs' (namespace)>
11+
# Need to check if 'mkdocs' has '__version__' attribute
12+
13+
mkdocs_installed = hasattr(mkdocs, "__version__")
14+
except (ImportError, AttributeError):
15+
mkdocs_installed = False
1216

1317

1418
@pytest.mark.skipif(
15-
"mkdocs" not in sys.modules,
19+
not mkdocs_installed,
1620
reason=(
1721
"Requires the MkDocs library. "
1822
"And only test documentation in documentation building CI."

0 commit comments

Comments
 (0)