Skip to content

Commit 2a5b609

Browse files
authored
Merge pull request #800 from DHI/fix_pfs_warnings
Fix deprecated escape chars
2 parents 6bb10a6 + 1c8f160 commit 2a5b609

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

tests/test_pfs.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import sys
2+
from datetime import datetime
13
from io import StringIO
24
from pathlib import Path
3-
import sys
5+
6+
import pandas as pd
47
import pytest
8+
59
import mikeio
6-
import pandas as pd
7-
from datetime import datetime
810

911

1012
@pytest.fixture
@@ -667,7 +669,7 @@ def test_empty(tmp_path: Path) -> None:
667669

668670

669671
def test_difficult_chars_in_str(tmp_path: Path) -> None:
670-
text = """
672+
text = r"""
671673
[ENGINE]
672674
A = 'str,s/d\sd.dfs0'
673675
B = "str,sd'sd.dfs0"
@@ -680,13 +682,13 @@ def test_difficult_chars_in_str(tmp_path: Path) -> None:
680682
pfs = mikeio.PfsDocument.from_text(text)
681683

682684
assert isinstance(pfs.ENGINE.A, str)
683-
assert pfs.ENGINE.A == "str,s/d\sd.dfs0"
685+
assert pfs.ENGINE.A == r"str,s/d\sd.dfs0"
684686

685687
# NOTE: B will appear wrong as a list with one item
686688
assert isinstance(pfs.ENGINE.B[0], str)
687689
assert pfs.ENGINE.B[0] == "str,sd'sd.dfs0"
688690
assert isinstance(pfs.ENGINE.C, str)
689-
assert pfs.ENGINE.C == "|sd\U0001f600s\d.dfs0|"
691+
assert pfs.ENGINE.C == "|sd\U0001f600s\\d.dfs0|"
690692
assert isinstance(pfs.ENGINE.D, str)
691693
assert pfs.ENGINE.E == "|str,s\U0001f600+-s_d.dfs0|"
692694

@@ -695,15 +697,15 @@ def test_difficult_chars_in_str(tmp_path: Path) -> None:
695697

696698
outlines = Path(outfile).read_text().splitlines()
697699

698-
assert outlines[5].strip() == "A = 'str,s/d\sd.dfs0'"
700+
assert outlines[5].strip() == "A = 'str,s/d\\sd.dfs0'"
699701
assert outlines[6].strip() == "B = 'str,sd'sd.dfs0'"
700-
assert outlines[7].strip() == "C = |sd's\d.dfs0|"
702+
assert outlines[7].strip() == "C = |sd's\\d.dfs0|"
701703
assert outlines[8].strip() == "D = |str'd.dfs0|"
702704
assert outlines[9].strip() == "E = |str,s'+-s_d.dfs0|"
703705

704706

705707
def test_difficult_chars_in_str2(tmp_path: Path) -> None:
706-
text = """
708+
text = r"""
707709
[ENGINE]
708710
A = 'str,s/d\sd.dfs0'
709711
B = "str,sd'sd.dfs0"
@@ -719,7 +721,7 @@ def test_difficult_chars_in_str2(tmp_path: Path) -> None:
719721

720722
outlines = Path(outfile).read_text().splitlines()
721723

722-
assert outlines[5].strip() == "A = 'str,s/d\sd.dfs0'"
724+
assert outlines[5].strip() == "A = 'str,s/d\\sd.dfs0'"
723725
assert outlines[6].strip() == "B = 'str,sd'sd.dfs0'"
724726
assert outlines[7].strip() == "C = |str'd.dfs0|"
725727
assert outlines[8].strip() == "D = |str,s'+-s_d.dfs0|"
@@ -914,7 +916,7 @@ def test_nested_quotes(tmp_path: Path) -> None:
914916

915917

916918
def test_filename_in_list(tmp_path: Path) -> None:
917-
text = """
919+
text = r"""
918920
[EcolabTemplateSpecification]
919921
TemplateFile_A = |.\Test1_OLSZ_OL_WQsetups.ecolab|
920922
TemplateFile_OL = |.\Test1_OLSZ_OL_WQsetups.ecolab|, 2019, 4, 25, 14, 51, 35

0 commit comments

Comments
 (0)