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

Function setuptestfs

testing/_py/test_local.py:473–514  ·  testing/_py/test_local.py::setuptestfs
(path)

Source from the content-addressed store, hash-verified

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