Skip to content

Commit

Permalink
dedent
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 committed May 1, 2024
1 parent a30e442 commit b603185
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 32 deletions.
21 changes: 12 additions & 9 deletions api/tests/unit_tests/utils/position_helper/test_position_helper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from textwrap import dedent

import pytest

from core.utils.position_helper import get_position_map
Expand All @@ -6,15 +8,16 @@
@pytest.fixture
def prepare_example_positions_yaml(tmp_path, monkeypatch) -> str:
monkeypatch.chdir(tmp_path)
tmp_path.joinpath("example_positions.yaml").write_text("""
- first
- second
# - commented
- third
- 9999999999999
- forth
""")
tmp_path.joinpath("example_positions.yaml").write_text(dedent(
"""\
- first
- second
# - commented
- third
- 9999999999999
- forth
"""))
return str(tmp_path)


Expand Down
50 changes: 27 additions & 23 deletions api/tests/unit_tests/utils/yaml/test_yaml_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from textwrap import dedent

import pytest
from yaml import YAMLError

Expand All @@ -12,36 +14,38 @@
def prepare_example_yaml_file(tmp_path, monkeypatch) -> str:
monkeypatch.chdir(tmp_path)
file_path = tmp_path.joinpath(EXAMPLE_YAML_FILE)
file_path.write_text("""
address:
city: Example City
country: Example Country
age: 30
gender: male
languages:
- Python
- Java
- C++
empty_key:
""")
file_path.write_text(dedent(
"""\
address:
city: Example City
country: Example Country
age: 30
gender: male
languages:
- Python
- Java
- C++
empty_key:
"""))
return str(file_path)


@pytest.fixture
def prepare_invalid_yaml_file(tmp_path, monkeypatch) -> str:
monkeypatch.chdir(tmp_path)
file_path = tmp_path.joinpath(INVALID_YAML_FILE)
file_path.write_text("""
address:
city: Example City
country: Example Country
age: 30
gender: male
languages:
- Python
- Java
- C++
""")
file_path.write_text(dedent(
"""\
address:
city: Example City
country: Example Country
age: 30
gender: male
languages:
- Python
- Java
- C++
"""))
return str(file_path)


Expand Down

0 comments on commit b603185

Please sign in to comment.