Commit 06935819 authored by Kirill Smelkov's avatar Kirill Smelkov

golang: tests: Normalize paths to use / delimiter in doctests's got

Else on Windows e.g. test_defer_excchain_traceback fails as

    E           Failed: not equal:
    E           Differences (unified diff with -expected +actual):
    E               @@ -1,8 +1,8 @@
    E                Traceback (most recent call last):
    E               -  File "PYGOLANG/golang/golang_test.py", line ..., in test_defer_excchain_traceback
    E               +  File "PYGOLANG\golang\golang_test.py", line 1524, in test_defer_excchain_traceback
    E                    alpha()
    E               -  File "PYGOLANG/golang/golang_test.py", line ..., in alpha
    E               +  File "PYGOLANG\golang\golang_test.py", line 1521, in alpha
    E                    beta()
    E               -  File "PYGOLANG/golang/golang_test.py", line ..., in beta
    E               +  File "PYGOLANG\golang\golang_test.py", line 1520, in beta
    E                    raise RuntimeError("gamma")
    E                RuntimeError: gamma
parent a5ce8175
......@@ -1807,6 +1807,13 @@ def assertDoc(want, got):
got = got.replace(dir_pygolang, "PYGOLANG") # /home/x/.../pygolang -> PYGOLANG
got = got.replace(udir_pygolang, "PYGOLANG") # ~/.../pygolang -> PYGOLANG
# got: normalize PYGOLANG\a\b\c -> PYGOLANG/a/b/c
# a\b\c\d.py -> a/b/c/d.py
def _(m):
return m.group(0).replace(os.path.sep, '/')
got = re.sub(r"(?<=PYGOLANG)[^\s]+(?=\s)", _, got)
got = re.sub(r"([\w\\\.]+)(?=\.py)", _, got)
# want: process conditionals
# PY39(...) -> ... if py ≥ 3.9 else ø (inline)
# `... +PY39` -> ... if py ≥ 3.9 else ø (whole line)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment