def test_source_of_class_at_eof_without_newline(tmpdir, _sys_snapshot) -> None: # this test fails because the implicit inspect.getsource(A) below # does not return the "x = 1" last line. source = Source(""" class A: def method(self): x = 1 """) path = tmpdir.join("a.py") path.write(source) s2 = Source(tmpdir.join("a.py").pyimport().A) assert str(source).strip() == str(s2).strip()
def site(tmpdir): flag = (tmpdir / 'TEST_SITE') flag.write('') marv_conf = (tmpdir / 'marv.conf') marv_conf.write(MARV_CONF) # make scanroots for sitename in ('foo',): for idx, name in enumerate(['a', 'b']): name = '{}_{}'.format(sitename, name) path = tmpdir / 'scanroots' / sitename / name path.write(str(idx), ensure=True) yield Site(marv_conf.strpath)