| 471 | |
| 472 | |
| 473 | def 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; |
| 502 | import otherdir.a |
| 503 | value = otherdir.a.result |
| 504 | """, |
| 505 | encoding="utf-8", |
| 506 | ) |
| 507 | module_d = otherdir.ensure("d.py") |
| 508 | module_d.write_text( |
| 509 | """import py; |
| 510 | from otherdir import a |
| 511 | value2 = a.result |
| 512 | """, |
| 513 | encoding="utf-8", |
| 514 | ) |
| 515 | |
| 516 | |
| 517 | win32only = pytest.mark.skipif( |