MCPcopy
hub / github.com/pytest-dev/pytest / setuptestfs

Function setuptestfs

testing/_py/test_local.py:473–514  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

471
472
473def setuptestfs(path):
474 if path.join("samplefile").check():
475 return
476 # print "setting up test fs for", repr(path)
477 samplefile = path.ensure("samplefile")
478 samplefile.write_text("samplefile\n", encoding="utf-8")
479
480 execfile = path.ensure("execfile")
481 execfile.write_text("x=42", encoding="utf-8")
482
483 execfilepy = path.ensure("execfile.py")
484 execfilepy.write_text("x=42", encoding="utf-8")
485
486 d = {1: 2, "hello": "world", "answer": 42}
487 path.ensure("samplepickle").dump(d)
488
489 sampledir = path.ensure("sampledir", dir=1)
490 sampledir.ensure("otherfile")
491
492 otherdir = path.ensure("otherdir", dir=1)
493 otherdir.ensure("__init__.py")
494
495 module_a = otherdir.ensure("a.py")
496 module_a.write_text("from .b import stuff as result\n", encoding="utf-8")
497 module_b = otherdir.ensure("b.py")
498 module_b.write_text('stuff="got it"\n', encoding="utf-8")
499 module_c = otherdir.ensure("c.py")
500 module_c.write_text(
501 """import py;
502import otherdir.a
503value = otherdir.a.result
504""",
505 encoding="utf-8",
506 )
507 module_d = otherdir.ensure("d.py")
508 module_d.write_text(
509 """import py;
510from otherdir import a
511value2 = a.result
512""",
513 encoding="utf-8",
514 )
515
516
517win32only = pytest.mark.skipif(

Callers 1

path1Function · 0.85

Calls 5

joinMethod · 0.80
ensureMethod · 0.80
write_textMethod · 0.80
dumpMethod · 0.80
checkMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…