1
1
import pytest
2
2
import os
3
+ import re
4
+ from pathlib import Path
3
5
4
6
from traitlets .config import Config
5
7
@@ -24,7 +26,8 @@ def test_coursedir_format_path(conf):
24
26
expected = os .path .join (coursedir .root , "step" , "student_id" , "assignment_id" )
25
27
assert coursedir .format_path ("step" , "student_id" , "assignment_id" ) == expected
26
28
27
- expected = os .path .join (coursedir .root .replace ("-" , r"\-" ), "step" , "student_id" , "assignment_id" )
29
+ escaped = Path (re .escape (coursedir .root ))
30
+ expected = str (escaped / "step" / "student_id" / "assignment_id" )
28
31
assert coursedir .format_path ("step" , "student_id" , "assignment_id" , escape = True ) == expected
29
32
30
33
@@ -35,5 +38,6 @@ def test_coursedir_format_path_with_specials(conf):
35
38
expected = os .path .join ("/[test] root" , "step" , "student_id" , "assignment_id" )
36
39
assert coursedir .format_path ("step" , "student_id" , "assignment_id" ) == expected
37
40
38
- expected = os .path .join (r"/\[test\]\ root" , "step" , "student_id" , "assignment_id" )
41
+ escaped = Path (re .escape (coursedir .root ))
42
+ expected = str (escaped / "step" / "student_id" / "assignment_id" )
39
43
assert coursedir .format_path ("step" , "student_id" , "assignment_id" , escape = True ) == expected
0 commit comments