def test_existing_file(self, editor, tmpdir): """Test editing an existing file.""" path = tmpdir / 'foo.txt' path.ensure() editor.edit_file(str(path)) editor._proc.finished.emit(0, QProcess.NormalExit) assert path.exists()
def setuptestfs(self, path): # print "setting up test fs for", repr(path) samplefile = path.ensure("samplefile") samplefile.write("samplefile\n") execfile = path.ensure("execfile") execfile.write("x=42") execfilepy = path.ensure("execfile.py") execfilepy.write("x=42") d = {1: 2, "hello": "world", "answer": 42} path.ensure("samplepickle").dump(d) sampledir = path.ensure("sampledir", dir=1) sampledir.ensure("otherfile") otherdir = path.ensure("otherdir", dir=1) otherdir.ensure("__init__.py") module_a = otherdir.ensure("a.py") module_a.write("from .b import stuff as result\n") module_b = otherdir.ensure("b.py") module_b.write('stuff="got it"\n') module_c = otherdir.ensure("c.py") module_c.write( dedent( """ import py; import otherdir.a value = otherdir.a.result """ ) ) module_d = otherdir.ensure("d.py") module_d.write( dedent( """ import py; from otherdir import a value2 = a.result """ ) )