e3.testsuite.report.index
=========================

.. py:module:: e3.testsuite.report.index

.. autoapi-nested-parse::

   Lightweight index for test results.

   Loading all test results for big testsuites can take a lot of time because of
   all the YAML parsing involved. This module provides helpers to efficiently read
   and write an index of test results. This index contains only test names,
   statuses and messages, so it is super fast to read. From there, users can load
   individual test full results only when needed.



Classes
-------

.. autoapisummary::

   e3.testsuite.report.index.ReportIndexEntry
   e3.testsuite.report.index.ReportIndex


Module Contents
---------------

.. py:class:: ReportIndexEntry

   ReportIndex entry for a single test result.


   .. py:attribute:: index
      :type:  ReportIndex


   .. py:attribute:: summary
      :type:  e3.testsuite.result.TestResultSummary


   .. py:attribute:: filename
      :type:  str


   .. py:property:: test_name
      :type: str



   .. py:property:: status
      :type: e3.testsuite.result.TestStatus



   .. py:property:: msg
      :type: Optional[str]



   .. py:property:: failure_reasons
      :type: Set[e3.testsuite.result.FailureReason]



   .. py:property:: time
      :type: Optional[float]



   .. py:property:: info
      :type: Dict[str, str]



   .. py:method:: load() -> e3.testsuite.result.TestResult


.. py:class:: ReportIndex(results_dir: str)

   Lightweight index for test results.


   .. py:attribute:: INDEX_FILENAME
      :value: '_index.json'



   .. py:attribute:: INDEX_MAGIC
      :value: 'e3.testsuite.report.index.ReportIndex:1'



   .. py:attribute:: results_dir

      Directory that contain test results (YAML files).



   .. py:attribute:: entries
      :type:  Dict[str, ReportIndexEntry]

      Map test names to their ReportIndexEntry instances.



   .. py:attribute:: status_counters

      Number of test result for each test status.



   .. py:attribute:: duration
      :type:  Optional[float]
      :value: None


      Optional number of seconds for the total duration of the testsuite run.



   .. py:method:: save_and_add_result(result: e3.testsuite.result.TestResult) -> None

      Save a test result in the results directory and add it to the index.

      :param result: Test result to save/add.



   .. py:method:: add_result(result: e3.testsuite.result.TestResultSummary, filename: str) -> None

      Add an entry to this index for the given test result.

      Note that unlike ``save_and_add_result``, this does not write the
      result data in the results dir: it is up to the caller to make sure of
      that.

      :param result: Result to add.
      :param filename: Name of the file that contains test result data.



   .. py:method:: read(results_dir: str) -> ReportIndex
      :classmethod:


      Read the index in the given results directory.



   .. py:method:: write() -> None

      Write the index on disk.



   .. py:property:: has_failures
      :type: bool


      Return whether there is at least one FAIL/ERROR test status.



