1
+ import sys
2
+ from datetime import datetime
1
3
from io import StringIO
2
4
from pathlib import Path
3
- import sys
5
+
6
+ import pandas as pd
4
7
import pytest
8
+
5
9
import mikeio
6
- import pandas as pd
7
- from datetime import datetime
8
10
9
11
10
12
@pytest .fixture
@@ -667,7 +669,7 @@ def test_empty(tmp_path: Path) -> None:
667
669
668
670
669
671
def test_difficult_chars_in_str (tmp_path : Path ) -> None :
670
- text = """
672
+ text = r """
671
673
[ENGINE]
672
674
A = 'str,s/d\sd.dfs0'
673
675
B = "str,sd'sd.dfs0"
@@ -680,13 +682,13 @@ def test_difficult_chars_in_str(tmp_path: Path) -> None:
680
682
pfs = mikeio .PfsDocument .from_text (text )
681
683
682
684
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"
684
686
685
687
# NOTE: B will appear wrong as a list with one item
686
688
assert isinstance (pfs .ENGINE .B [0 ], str )
687
689
assert pfs .ENGINE .B [0 ] == "str,sd'sd.dfs0"
688
690
assert isinstance (pfs .ENGINE .C , str )
689
- assert pfs .ENGINE .C == "|sd\U0001f600 s\d.dfs0|"
691
+ assert pfs .ENGINE .C == "|sd\U0001f600 s\\ d.dfs0|"
690
692
assert isinstance (pfs .ENGINE .D , str )
691
693
assert pfs .ENGINE .E == "|str,s\U0001f600 +-s_d.dfs0|"
692
694
@@ -695,15 +697,15 @@ def test_difficult_chars_in_str(tmp_path: Path) -> None:
695
697
696
698
outlines = Path (outfile ).read_text ().splitlines ()
697
699
698
- assert outlines [5 ].strip () == "A = 'str,s/d\sd.dfs0'"
700
+ assert outlines [5 ].strip () == "A = 'str,s/d\\ sd.dfs0'"
699
701
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|"
701
703
assert outlines [8 ].strip () == "D = |str'd.dfs0|"
702
704
assert outlines [9 ].strip () == "E = |str,s'+-s_d.dfs0|"
703
705
704
706
705
707
def test_difficult_chars_in_str2 (tmp_path : Path ) -> None :
706
- text = """
708
+ text = r """
707
709
[ENGINE]
708
710
A = 'str,s/d\sd.dfs0'
709
711
B = "str,sd'sd.dfs0"
@@ -719,7 +721,7 @@ def test_difficult_chars_in_str2(tmp_path: Path) -> None:
719
721
720
722
outlines = Path (outfile ).read_text ().splitlines ()
721
723
722
- assert outlines [5 ].strip () == "A = 'str,s/d\sd.dfs0'"
724
+ assert outlines [5 ].strip () == "A = 'str,s/d\\ sd.dfs0'"
723
725
assert outlines [6 ].strip () == "B = 'str,sd'sd.dfs0'"
724
726
assert outlines [7 ].strip () == "C = |str'd.dfs0|"
725
727
assert outlines [8 ].strip () == "D = |str,s'+-s_d.dfs0|"
@@ -914,7 +916,7 @@ def test_nested_quotes(tmp_path: Path) -> None:
914
916
915
917
916
918
def test_filename_in_list (tmp_path : Path ) -> None :
917
- text = """
919
+ text = r """
918
920
[EcolabTemplateSpecification]
919
921
TemplateFile_A = |.\Test1_OLSZ_OL_WQsetups.ecolab|
920
922
TemplateFile_OL = |.\Test1_OLSZ_OL_WQsetups.ecolab|, 2019, 4, 25, 14, 51, 35
0 commit comments