Skip to content
Snippets Groups Projects
Commit addae657 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Fix style

parent dd0eda61
No related branches found
No related tags found
No related merge requests found
Pipeline #64816 passed
...@@ -10,8 +10,8 @@ import typing ...@@ -10,8 +10,8 @@ import typing
from importlib.metadata import EntryPoint from importlib.metadata import EntryPoint
import tomli
import click import click
import tomli
from click.core import ParameterSource from click.core import ParameterSource
...@@ -643,7 +643,7 @@ def user_defaults_group( ...@@ -643,7 +643,7 @@ def user_defaults_group(
try: try:
del config[key] del config[key]
config.write() config.write()
except KeyError as e: except KeyError:
logger.error( logger.error(
f"Cannot delete object named `{key}' at `{config.path}'", f"Cannot delete object named `{key}' at `{config.path}'",
exc_info=True, exc_info=True,
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
"""Implements a global configuration system setup and readout.""" """Implements a global configuration system setup and readout."""
import os import collections.abc
import io import io
import json import json
import typing
import logging import logging
import os
import pathlib import pathlib
import collections.abc import typing
import tomli import tomli
import tomli_w import tomli_w
......
import os
import shutil
import filecmp import filecmp
import logging import logging
import os
import shutil
import pytest import pytest
from click.testing import CliRunner from click.testing import CliRunner
from expose.click import user_defaults_group from expose.click import user_defaults_group
...@@ -17,10 +18,10 @@ def _check_userdefaults_ex1_contents(rc): ...@@ -17,10 +18,10 @@ def _check_userdefaults_ex1_contents(rc):
assert rc["string"] == "this is a string" assert rc["string"] == "this is a string"
assert rc["integer"] == 42 assert rc["integer"] == 42
assert rc["float"] == 3.14 assert rc["float"] == 3.14
assert rc["boolean"] == True assert rc["boolean"] is True
assert rc["array"] == ["abc", 2, 2.78] assert rc["array"] == ["abc", 2, 2.78]
assert rc["bar"]["boolean"] == False assert rc["bar"]["boolean"] is False
assert rc["bar.boolean"] == False assert rc["bar.boolean"] is False
def test_rc_basic_loading(datadir): def test_rc_basic_loading(datadir):
...@@ -68,14 +69,14 @@ def test_rc_write(tmp_path): ...@@ -68,14 +69,14 @@ def test_rc_write(tmp_path):
# checks contents before writing # checks contents before writing
assert rc["section1"]["an_int"] == 15 assert rc["section1"]["an_int"] == 15
assert rc["section1"]["a_bool"] == True assert rc["section1"]["a_bool"] is True
assert rc["section1"]["a_float"] == 3.1415 assert rc["section1"]["a_float"] == 3.1415
assert rc["section1"]["baz"] == "fun" assert rc["section1"]["baz"] == "fun"
assert rc["section1"]["bar"] == "Python" assert rc["section1"]["bar"] == "Python"
# checks contents before writing - different way # checks contents before writing - different way
assert rc["section1.an_int"] == 15 assert rc["section1.an_int"] == 15
assert rc["section1.a_bool"] == True assert rc["section1.a_bool"] is True
assert rc["section1.a_float"] == 3.1415 assert rc["section1.a_float"] == 3.1415
assert rc["section1.baz"] == "fun" assert rc["section1.baz"] == "fun"
assert rc["section1.bar"] == "Python" assert rc["section1.bar"] == "Python"
...@@ -88,8 +89,8 @@ def test_rc_write(tmp_path): ...@@ -88,8 +89,8 @@ def test_rc_write(tmp_path):
assert len(rc2) == 1 assert len(rc2) == 1
assert rc["section1"]["an_int"] == 15 assert rc["section1"]["an_int"] == 15
assert rc["section1.an_int"] == 15 assert rc["section1.an_int"] == 15
assert rc["section1"]["a_bool"] == True assert rc["section1"]["a_bool"] is True
assert rc["section1.a_bool"] == True assert rc["section1.a_bool"] is True
assert rc["section1"]["a_float"] == 3.1415 assert rc["section1"]["a_float"] == 3.1415
assert rc["section1.a_float"] == 3.1415 assert rc["section1.a_float"] == 3.1415
assert rc["section1"]["baz"] == "fun" assert rc["section1"]["baz"] == "fun"
...@@ -110,7 +111,7 @@ def test_rc_delete(tmp_path): ...@@ -110,7 +111,7 @@ def test_rc_delete(tmp_path):
rc["section1.bar"] = "Python" rc["section1.bar"] = "Python"
assert rc["an_int"] == 15 assert rc["an_int"] == 15
assert rc["a_bool"] == True assert rc["a_bool"] is True
assert rc["a_float"] == 3.1415 assert rc["a_float"] == 3.1415
assert rc["section1.baz"] == "fun" assert rc["section1.baz"] == "fun"
assert rc["section1.bar"] == "Python" assert rc["section1.bar"] == "Python"
...@@ -272,24 +273,18 @@ def test_rc_click_writing(datadir, tmp_path): ...@@ -272,24 +273,18 @@ def test_rc_click_writing(datadir, tmp_path):
result = runner.invoke(cli, ["rm", "new-section.date"]) result = runner.invoke(cli, ["rm", "new-section.date"])
result = runner.invoke(cli, ["get", "new-section.date"]) result = runner.invoke(cli, ["get", "new-section.date"])
assert result.exit_code != 0 assert result.exit_code != 0
assert ( assert "Error: Cannot find object named `new-section.date'" in result.output
"Error: Cannot find object named `new-section.date'" in result.output
)
result = runner.invoke(cli, ["rm", "new-section"]) result = runner.invoke(cli, ["rm", "new-section"])
result = runner.invoke(cli, ["get", "new-section"]) result = runner.invoke(cli, ["get", "new-section"])
assert result.exit_code != 0 assert result.exit_code != 0
assert ( assert "Error: Cannot find object named `new-section'" in result.output
"Error: Cannot find object named `new-section'" in result.output
)
result = runner.invoke(cli, ["rm", "bar"]) result = runner.invoke(cli, ["rm", "bar"])
assert result.exit_code == 0 assert result.exit_code == 0
result = runner.invoke(cli, ["get", "bar"]) result = runner.invoke(cli, ["get", "bar"])
assert result.exit_code != 0 assert result.exit_code != 0
assert ( assert "Error: Cannot find object named `bar'" in result.output
"Error: Cannot find object named `bar'" in result.output
)
def test_rc_click_no_directory(datadir, tmp_path): def test_rc_click_no_directory(datadir, tmp_path):
...@@ -333,9 +328,7 @@ def test_rc_click_cannot_set(tmp_path): ...@@ -333,9 +328,7 @@ def test_rc_click_cannot_set(tmp_path):
result = runner.invoke(cli, ["set", "bar.boolean.error", "50"]) result = runner.invoke(cli, ["set", "bar.boolean.error", "50"])
assert result.exit_code != 0 assert result.exit_code != 0
assert ( assert "Error: Cannot set object named `bar.boolean.error'" in result.output
"Error: Cannot set object named `bar.boolean.error'" in result.output
)
def test_rc_click_cannot_delete(tmp_path): def test_rc_click_cannot_delete(tmp_path):
...@@ -358,9 +351,7 @@ def test_rc_click_cannot_delete(tmp_path): ...@@ -358,9 +351,7 @@ def test_rc_click_cannot_delete(tmp_path):
result = runner.invoke(cli, ["rm", "new-section"]) result = runner.invoke(cli, ["rm", "new-section"])
assert result.exit_code != 0 assert result.exit_code != 0
assert ( assert "Error: Cannot delete object named `new-section'" in result.output
"Error: Cannot delete object named `new-section'" in result.output
)
# the existing section should still work # the existing section should still work
result = runner.invoke(cli, ["rm", "bar"]) result = runner.invoke(cli, ["rm", "bar"])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment