Some proposed stdlib filesystem tests
オープン
まだ誰も着手していません。
3.12
tests
topic-IO
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- 平均マージ
- 1日 9時間
- マージ済み PR(30日)
- 558
説明
The following three tests are failing on Emscripten main because of my faulty dup implementation. @tiran didn't notice and fix it, and indeed the Python stdlib tests don't seem to notice that dup isn't working. I would be happy to make a PR adding these to the standard library tests given advice on where to put them.
def test_dup_pipe():
# See https://github.com/emscripten-core/emscripten/issues/14640
import os
[fdr1, fdw1] = os.pipe()
fdr2 = os.dup(fdr1)
fdw2 = os.dup2(fdw1, 50)
# Closing any of fdr, fdr2, fdw, or fdw2 will currently destroy the pipe.
# This bug is fixed upstream:
# https://github.com/emscripten-core/emscripten/pull/14685
s1 = b"some stuff"
s2 = b"other stuff to write"
os.write(fdw1, s1)
assert os.read(fdr2, 100) == s1
os.write(fdw2, s2)
assert os.read(fdr1, 100) == s2
def test_dup_temp_file():
# See https://github.com/emscripten-core/emscripten/issues/15012
import os
from tempfile import TemporaryFile
tf = TemporaryFile(buffering=0)
fd1 = os.dup(tf.fileno())
s = b"hello there!"
tf.write(s)
tf2 = open(fd1, "w+")
assert tf2.tell() == len(s)
# This next assertion actually demonstrates a bug in dup: the correct value
# to return should be b"".
assert os.read(fd1, 50) == b""
tf2.seek(1)
assert tf.tell() == 1
assert tf.read(100) == b"ello there!"
def test_dup_stdout():
# Test redirecting stdout using low level os.dup operations.
# This sort of redirection is used in pytest.
import os
import sys
from tempfile import TemporaryFile
tf = TemporaryFile(buffering=0)
save_stdout = os.dup(sys.stdout.fileno())
os.dup2(tf.fileno(), sys.stdout.fileno())
print("hi!!")
print("there...")
assert tf.tell() == len("hi!!\nthere...\n")
os.dup2(save_stdout, sys.stdout.fileno())
print("not captured")
os.dup2(tf.fileno(), sys.stdout.fileno())
print("captured")
assert tf.tell() == len("hi!!\nthere...\ncaptured\n")
os.dup2(save_stdout, sys.stdout.fileno())
os.close(save_stdout)
tf.seek(0)
assert tf.read(1000).decode() == "hi!!\nthere...\ncaptured\n"
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、os、ファイルディスクリプタ、パイプ、TemporaryFile を対象とする CPython 標準ライブラリのテストモジュールを特定し、その後 Emscripten 上で既存のファイルシステムテストを実行します。関連するファイルシステムの動作がテストされている箇所に、提案された 3 つのテストを追加します。標準ライブラリのテストスイートに含まれ、他のテストを退行させることなくパスすれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- testing-qa
- issue の種類
- 機能追加
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100