Skip to content

Commit 7446d63

Browse files
committed
refacotor: use pathlib.write_text
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 0c2ddc6 commit 7446d63

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

test/test_before_all.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def test(tmp_path):
3838

3939
# build the wheels
4040
before_all_command = (
41-
"""python -c "import os, sys;open('{project}/text_info.txt', 'w').write('sample text '+os.environ.get('TEST_VAL', ''))" && """
42-
'''python -c "import sys; open('{project}/python_prefix.txt', 'w').write(sys.prefix)"'''
41+
"""python -c "import os, pathlib, sys; pathlib.Path('{project}/text_info.txt').write_text('sample text '+os.environ.get('TEST_VAL', ''))" && """
42+
'''python -c "import pathlib, sys; pathlib.Path('{project}/python_prefix.txt').write_text(sys.prefix)"'''
4343
)
4444
actual_wheels = utils.cibuildwheel_run(
4545
project_dir,

test/test_before_build.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def test(tmp_path):
4141
project_with_before_build_asserts.generate(project_dir)
4242

4343
before_build = (
44-
"""python -c "import sys; f = open('{project}/pythonversion_bb.txt', 'w'); f.write(sys.version); f.close()" && """
45-
f'''python -c "import sys; f = open('{{project}}/pythonprefix_bb.txt', 'w'); f.write({SYS_PREFIX}); f.close()"'''
44+
"""python -c "import pathlib, sys; pathlib.Path('{project}/pythonversion_bb.txt').write_text(sys.version)" && """
45+
f'''python -c "import pathlib, sys; pathlib.Path('{{project}}/pythonprefix_bb.txt').write_text({SYS_PREFIX})"'''
4646
)
4747
frontend = "build"
4848
if utils.platform != "pyodide":

test/test_before_test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pathlib import Path
88
from unittest import TestCase
99
10-
PROJECT_DIR = Path(__file__).joinpath("..", "..").resolve()
10+
PROJECT_DIR = Path(__file__).parent.parent.resolve()
1111
1212
1313
class TestBeforeTest(TestCase):
@@ -39,8 +39,8 @@ def test(tmp_path, build_frontend_env):
3939
test_projects.new_c_project().generate(test_project_dir)
4040

4141
before_test_steps = [
42-
'''python -c "import os, sys; f = open('{project}/pythonversion_bt.txt', 'w'); f.write(sys.version); f.close()"''',
43-
'''python -c "import os, sys; f = open('{project}/pythonprefix_bt.txt', 'w'); f.write(sys.prefix); f.close()"''',
42+
'''python -c "import pathlib, sys; pathlib.Path('{project}/pythonversion_bt.txt').write_text(sys.version)"''',
43+
'''python -c "import pathlib, sys; pathlib.Path('{project}/pythonprefix_bt.txt').write_text(sys.prefix)"''',
4444
]
4545

4646
if utils.platform == "pyodide":

0 commit comments

Comments
 (0)