Where does drupal determine which theme file to use for an entity field? So I've got this problem where file_entity is ignoring the configured video formatter despite triple-checking the GUI configuration. Instead it's being rendered by theme_file_entity_file_video(), which shouldn't be happening.

But it is. So I'm digging back into core to see where the theme function responsible was established. I'm in drupal_render but I'm already seeing the theme function set improperly... 

So my question: Where does drupal determine which theme file/function to use for an entity field?

Clarification: my question is, "How/where does the theme registry get built for an entity?" I want to watch it get built with a debugger.
Everything can be overridden by one hook in any module so bear that in mind. 

The theme registry is where everything is stored in terms of theming for pages/entities. It all depends on the order here in determining the theme it will use. 

You can use the devel module and dpm out the theme registry:

https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_get_registry/7

It usually is built in this order: 


module where entity is created
module where function was called to get the entity
your theme directory


but at any point that could have been overridden