mirror of
https://github.com/danieldemus/pyp2spec.git
synced 2026-07-27 21:00:37 +02:00
Use tomllib from the standard library on Python 3.11+
This commit is contained in:
committed by
Karolina Surma
parent
d7966cb29e
commit
737036a322
@@ -2,7 +2,11 @@ from importlib.resources import read_text
|
||||
from textwrap import fill
|
||||
|
||||
import click
|
||||
import tomli
|
||||
|
||||
try:
|
||||
import tomllib
|
||||
except ImportError:
|
||||
import tomli as tomllib
|
||||
|
||||
from jinja2 import Template
|
||||
|
||||
@@ -22,7 +26,7 @@ class ConfigFile:
|
||||
"""Return loaded TOML configuration file contents."""
|
||||
|
||||
with open(self.filename, "rb") as configuration_file:
|
||||
loaded_contents = tomli.load(configuration_file)
|
||||
loaded_contents = tomllib.load(configuration_file)
|
||||
|
||||
return loaded_contents
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
click
|
||||
jinja2
|
||||
requests
|
||||
tomli
|
||||
tomli;python_version<"3.11"
|
||||
tomli-w
|
||||
packaging
|
||||
|
||||
@@ -27,7 +27,7 @@ install_requires =
|
||||
jinja2
|
||||
packaging
|
||||
requests
|
||||
tomli
|
||||
tomli;python_version<"3.11"
|
||||
tomli-w
|
||||
include_package_data = True
|
||||
|
||||
|
||||
@@ -5,7 +5,11 @@ to prevent loading from the internet on each request.
|
||||
|
||||
import betamax
|
||||
import pytest
|
||||
import tomli
|
||||
|
||||
try:
|
||||
import tomllib
|
||||
except ImportError:
|
||||
import tomli as tomllib
|
||||
|
||||
from pyp2spec.pyp2conf import PypiPackage, create_config_contents
|
||||
|
||||
@@ -42,7 +46,7 @@ def test_automatically_generated_config_is_valid(betamax_parametrized_session, c
|
||||
)
|
||||
|
||||
with open(f"tests/test_configs/default_python-{package}.conf", "rb") as config_file:
|
||||
loaded_contents = tomli.load(config_file)
|
||||
loaded_contents = tomllib.load(config_file)
|
||||
|
||||
assert config == loaded_contents
|
||||
|
||||
@@ -66,7 +70,7 @@ def test_config_with_customization_is_valid(betamax_session):
|
||||
)
|
||||
|
||||
with open(f"tests/test_configs/customized_{package}.conf", "rb") as config_file:
|
||||
loaded_contents = tomli.load(config_file)
|
||||
loaded_contents = tomllib.load(config_file)
|
||||
|
||||
assert config == loaded_contents
|
||||
|
||||
@@ -85,7 +89,7 @@ def test_archful_package(betamax_session, changelog):
|
||||
)
|
||||
|
||||
with open(f"tests/test_configs/customized_{package}.conf", "rb") as config_file:
|
||||
loaded_contents = tomli.load(config_file)
|
||||
loaded_contents = tomllib.load(config_file)
|
||||
|
||||
assert config["archful"] == loaded_contents["archful"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user