| 92 | assert path.joinpath("samplefile").exists() |
| 93 | |
| 94 | def setuptestfs(self, path: Path) -> None: |
| 95 | # print "setting up test fs for", repr(path) |
| 96 | samplefile = path / "samplefile" |
| 97 | samplefile.write_text("samplefile\n") |
| 98 | |
| 99 | execfile = path / "execfile" |
| 100 | execfile.write_text("x=42") |
| 101 | |
| 102 | execfilepy = path / "execfile.py" |
| 103 | execfilepy.write_text("x=42") |
| 104 | |
| 105 | d = {1: 2, "hello": "world", "answer": 42} |
| 106 | path.joinpath("samplepickle").write_bytes(pickle.dumps(d, 1)) |
| 107 | |
| 108 | sampledir = path / "sampledir" |
| 109 | sampledir.mkdir() |
| 110 | sampledir.joinpath("otherfile").touch() |
| 111 | |
| 112 | otherdir = path / "otherdir" |
| 113 | otherdir.mkdir() |
| 114 | otherdir.joinpath("__init__.py").touch() |
| 115 | |
| 116 | module_a = otherdir / "a.py" |
| 117 | module_a.write_text("from .b import stuff as result\n") |
| 118 | module_b = otherdir / "b.py" |
| 119 | module_b.write_text('stuff="got it"\n') |
| 120 | module_c = otherdir / "c.py" |
| 121 | module_c.write_text( |
| 122 | dedent( |
| 123 | """ |
| 124 | import pluggy; |
| 125 | import otherdir.a |
| 126 | value = otherdir.a.result |
| 127 | """ |
| 128 | ) |
| 129 | ) |
| 130 | module_d = otherdir / "d.py" |
| 131 | module_d.write_text( |
| 132 | dedent( |
| 133 | """ |
| 134 | import pluggy; |
| 135 | from otherdir import a |
| 136 | value2 = a.result |
| 137 | """ |
| 138 | ) |
| 139 | ) |
| 140 | |
| 141 | def test_smoke_test(self, path1: Path) -> None: |
| 142 | obj = import_path(path1 / "execfile.py", root=path1) |