示例#1
0
    def _check_nodes_have_same_collection(self):
        """Return True if all nodes have collected the same items.

        If collections differ, this method returns False while logging
        the collection differences and posting collection errors to
        pytest_collectreport hook.
        """
        node_collection_items = list(self.registered_collections.items())
        first_node, col = node_collection_items[0]
        same_collection = True

        for node, collection in node_collection_items[1:]:
            msg = report_collection_diff(
                col, collection, first_node.gateway.id, node.gateway.id
            )
            if not msg:
                continue

            same_collection = False
            self.log(msg)

            if self.config is None:
                continue

            rep = CollectReport(node.gateway.id, "failed", longrepr=msg, result=[])
            self.config.hook.pytest_collectreport(report=rep)

        return same_collection
 def deserialize_report(self, reporttype, report):
     from _pytest.runner import TestReport, CollectReport
     from pytest import Item
     if 'result' in report:
         newresult = []
         for item in report['result']:
             item_obj = Item(item['name'],
                             config=self.config,
                             session=self.session)
             newresult.append(item_obj)
         report['result'] = newresult
     if reporttype == "test":
         return TestReport(**report)
     elif reporttype == "collect":
         return CollectReport(**report)
     else:
         raise RuntimeError("Invalid report type: {}".format(reporttype))