DisplayUtility

The display utility is a PyFit enhancement to the Fit Library that allows you to display the current content of a collection within a DoFixture or a SequenceFixture. It's invoked by specifying $Display as the return type in the method metadata. The return value is a tuple with three values: the collection to display, the list of field names, and a dictionary containing the metadata for the requested fields.

The collection is specified in the same way as for RowFixture, ArrayFixture, SetFixture or SubsetFixture: as a list, a tuple, an iterator or a dictionary. If it's a dictionary, the entries will be sorted by key and then the values will be used as the collection.

The field list is a simple list of strings, one field name per string. The metadata dictionary is in the same format as the metadata dictionaries normally required for type adapters.

If metadata is missing, DisplayUtility will use str() to attempt to display the values. Fields that are not in an object will be marked as ignored (grey background) with a "[not found]" message; values that cannot be displayed because they have neither metadata nor support for str() will be marked as "[cannot display]" with an error (red) background. In the latter case, the column head will also be marked with the message "metadata missing" with a red background. The "metadata missing" message will not be generated if all the values in the column can be displayed using str(), however.

DisplayUtility cannot be invoked directly as a fixture. This may be changed in release 0.9.

The MusicPlayer example shows how it can be used.