Commit d9505256 authored by Kirill Smelkov's avatar Kirill Smelkov

gpython: tests: Don't assume path delimiter is /

Because on Windows it is \ and using / for it to scan in path fails and
leads to test_pymain_opt failure:

     E             Full diff:
     E               [
     E                'sys.flags.debug:      0',
     E                'sys.flags.optimize:   0',
     E                '__debug__:            True',
     E                'assert:               True',
     E                'docstrings:           True',
     E                'import mod.py:        '
     E             -  'C:\\users\\kirr\\Temp\\modpy_imports_fromvmgs8go4\\__pycache__/mod.cpython-310.pyc',
     E             ?                                            ^^  ----
     E             +  'C:\\users\\kirr\\Temp\\modpy_imports_from850gb81s\\__pycache__/mod.cpython-310.pyc',
     E             ?                                            ^^^ +++
     E               ]

Here the difference is because gpython/testprog/print_opt.py failed to
detect tmpd prefix and strip it.
parent 161629e6
# -*- coding: utf-8 -*-
# Copyright (C) 2020 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
# Copyright (C) 2020-2023 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
......@@ -61,9 +61,10 @@ def modpy_imports_from():
else:
raise AssertionError("module 'mod' is already there")
tmpd = tempfile.mkdtemp('', 'modpy_imports_from')
tmpd = tempfile.mkdtemp('', 'modpy_imports_from')
tmpd_ = tmpd + os.path.sep
try:
pymod = "%s/mod.py" % tmpd
pymod = tmpd_ + "mod.py"
with open(pymod, "w") as f:
f.write("# hello up there\n")
......@@ -73,9 +74,9 @@ def modpy_imports_from():
files = set()
for dirpath, dirnames, filenames in os.walk(tmpd):
for _ in filenames:
f = '%s/%s' % (dirpath, _)
if f.startswith(tmpd+'/'):
f = f[len(tmpd+'/'):]
f = os.path.join(dirpath, _)
if f.startswith(tmpd_):
f = f[len(tmpd_):]
files.add(f)
......
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