def inline_genitems(self, *args): # config = self.parseconfig(*args) config = self.parseconfigure(*args) rec = self.getreportrecorder(config) session = Session(config) config.hook.pytest_sessionstart(session=session) session.perform_collect() config.hook.pytest_sessionfinish(session=session, exitstatus=EXIT_OK) return session.items, rec
def getpathnode(self, path): config = self.parseconfigure(path) session = Session(config) x = session.fspath.bestrelpath(path) config.hook.pytest_sessionstart(session=session) res = session.perform_collect([x], genitems=False)[0] config.hook.pytest_sessionfinish(session=session, exitstatus=EXIT_OK) return res
def getnode(self, config, arg): session = Session(config) assert "::" not in str(arg) p = py.path.local(arg) config.hook.pytest_sessionstart(session=session) res = session.perform_collect([str(p)], genitems=False)[0] config.hook.pytest_sessionfinish(session=session, exitstatus=EXIT_OK) return res
def group_in_pytest(group): from _pytest.config import _prepareconfig from _pytest.main import Session from _pytest.python import FixtureManager from _pytest.mark import MarkMapping config = _prepareconfig(args="") session = Session(config) session._fixturemanager = FixtureManager(session) l = [list(MarkMapping(i.keywords)._mymarks) for i in session.perform_collect()] groups = set([item for sublist in l for item in sublist]) return group in groups
def test_collect_topdir(self, testdir): p = testdir.makepyfile("def test_func(): pass") id = "::".join([p.basename, "test_func"]) # XXX migrate to collectonly? (see below) config = testdir.parseconfig(id) topdir = testdir.tmpdir rcol = Session(config) assert topdir == rcol.fspath #rootid = rcol.nodeid #root2 = rcol.perform_collect([rcol.nodeid], genitems=False)[0] #assert root2 == rcol, rootid colitems = rcol.perform_collect([rcol.nodeid], genitems=False) assert len(colitems) == 1 assert colitems[0].fspath == p
def getpathnode(self, path): """Return the collection node of a file. This is like :py:meth:`getnode` but uses :py:meth:`parseconfigure` to create the (configured) pytest Config instance. :param path: a :py:class:`py.path.local` instance of the file """ config = self.parseconfigure(path) session = Session(config) x = session.fspath.bestrelpath(path) config.hook.pytest_sessionstart(session=session) res = session.perform_collect([x], genitems=False)[0] config.hook.pytest_sessionfinish(session=session, exitstatus=EXIT_OK) return res
def getnode(self, config, arg): """Return the collection node of a file. :param config: :py:class:`_pytest.config.Config` instance, see :py:meth:`parseconfig` and :py:meth:`parseconfigure` to create the configuration. :param arg: A :py:class:`py.path.local` instance of the file. """ session = Session(config) assert '::' not in str(arg) p = py.path.local(arg) config.hook.pytest_sessionstart(session=session) res = session.perform_collect([str(p)], genitems=False)[0] config.hook.pytest_sessionfinish(session=session, exitstatus=EXIT_OK) return res
def getnode(self, config, arg): """Return the collection node of a file. :param config: :py:class:`_pytest.orig.config.Config` instance, see :py:meth:`parseconfig` and :py:meth:`parseconfigure` to create the configuration. :param arg: A :py:class:`py.path.local` instance of the file. """ session = Session(config) assert '::' not in str(arg) p = py.path.local(arg) config.hook.pytest_sessionstart(session=session) res = session.perform_collect([str(p)], genitems=False)[0] config.hook.pytest_sessionfinish(session=session, exitstatus=EXIT_OK) return res
def getpathnode(self, path): """Return the collection node of a file. This is like :py:meth:`getnode` but uses :py:meth:`parseconfigure` to create the (configured) pytest Config instance. :param path: a :py:class:`py.path.local` instance of the file """ config = self.parseconfigure(path) session = Session(config) x = session.fspath.bestrelpath(path) config.hook.pytest_sessionstart(session=session) res = session.perform_collect([x], genitems=False)[0] config.hook.pytest_sessionfinish(session=session, exitstatus=ExitCode.OK) return res