Some proposed stdlib filesystem tests
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- testing-qa
Direzione di ricerca
Inizia individuando il modulo di test della libreria standard di CPython che copre os, i descrittori di file, le pipe e TemporaryFile, quindi esegui i test esistenti del filesystem sotto Emscripten. Aggiungi i tre test proposti nel punto in cui viene testato il comportamento correlato del filesystem; il lavoro è completato quando sono inclusi nella suite della libreria standard e superano i test senza introdurre regressioni negli altri test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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"
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 36k
- Merge medio
- 1g 9h
- PR unite (30g)
- 558
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python/cpython
-
docs pending
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
stdlib type-feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
stdlib type-feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
build type-bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
stdlib topic-email type-feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Tutte le issue di python/cpython
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
zostera/django-bootstrap4#894 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
use-agent-os/agent-os#3276 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
NousResearch/hermes-agent#117848 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
zilliztech/memsearch#759 ·