Skip to content

Commit 027a472

Browse files
authored
Merge pull request #3350 from ofek/fix-test-warning
Fix warning in test suite
2 parents 245649b + eb35788 commit 027a472

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

docs/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ alabaster==0.7.12
22
Sphinx==5.1.1
33
sphinx-rtd-theme==1.0.0
44
sphinx-copybutton==0.5.1
5+
importlib-metadata; python_version < '3.8'

docs/source/conf.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@
1717

1818
# -- Project information -----------------------------------------------------
1919

20+
import sys
2021

21-
import pkg_resources
2222
import sphinx_rtd_theme
2323

24+
if sys.version_info >= (3, 8):
25+
from importlib.metadata import Distribution
26+
else:
27+
from importlib_metadata import Distribution
28+
2429
html_theme = "sphinx_rtd_theme"
2530

2631
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
@@ -30,7 +35,7 @@
3035
author = "Will McGugan"
3136

3237
# The full version, including alpha/beta/rc tags
33-
release = pkg_resources.get_distribution("rich").version
38+
release = Distribution.from_name("rich").version
3439

3540

3641
# -- General configuration ---------------------------------------------------

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pytest-cov = "^3.0.0"
4444
attrs = "^21.4.0"
4545
pre-commit = "^2.17.0"
4646
asv = "^0.5.1"
47+
importlib-metadata = { version = "*", python = "<3.8" }
4748

4849
[build-system]
4950
requires = ["poetry-core>=1.0.0"]

tests/test_syntax.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import sys
44
import tempfile
55

6-
import pkg_resources
76
import pytest
87
from pygments.lexers import PythonLexer
98

@@ -21,7 +20,12 @@
2120

2221
from .render import render
2322

24-
PYGMENTS_VERSION = pkg_resources.get_distribution("pygments").version
23+
if sys.version_info >= (3, 8):
24+
from importlib.metadata import Distribution
25+
else:
26+
from importlib_metadata import Distribution
27+
28+
PYGMENTS_VERSION = Distribution.from_name("pygments").version
2529
OLD_PYGMENTS = PYGMENTS_VERSION == "2.13.0"
2630

2731
CODE = '''\

0 commit comments

Comments
 (0)