old_contents: # -*- coding: utf-8 -*-
  
  """Test plugin system."""
  
  
  #------------------------------------------------------------------------------
  # Imports
  #------------------------------------------------------------------------------
  
  import os.path as op
  
  from ..core import save_text
  from ..plugin import (IPluginRegistry, IPlugin, discover_plugins,
                        iter_plugins_dirs)
  
  
  #------------------------------------------------------------------------------
  # Fixtures
  #------------------------------------------------------------------------------
  
  def setup():
      IPluginRegistry.plugins = []
  
  
  def teardown():
      IPluginRegistry.plugins = []
  
  
  #------------------------------------------------------------------------------
  # Tests
  #------------------------------------------------------------------------------
  
  def test_plugin_registration():
      class MyPlugin(IPlugin):
          pass
  
      assert IPluginRegistry.plugins == [MyPlugin]
  
  
  def test_discover_plugins(tempdir):
      path = op.join(tempdir, 'my_plugin.py')
      contents = '''from podoc import IPlugin\nclass MyPlugin(IPlugin): pass'''
      save_text(path, contents)
      plugins = discover_plugins([tempdir])
      assert plugins
      assert plugins[0].__name__ == 'MyPlugin'
  
  
  def test_iter_plugins_dirs():
      assert 'json' in [op.basename(plugin_dir)
                        for plugin_dir in iter_plugins_dirs()]
  
new_contents: # -*- coding: utf-8 -*-
  
  """Test plugin system."""
  
  
  #------------------------------------------------------------------------------
  # Imports
  #------------------------------------------------------------------------------
  
  import os.path as op
  
  from ..core import save_text
  from ..plugin import (IPluginRegistry, IPlugin, discover_plugins,
                        iter_plugins_dirs, iter_plugin_test_files)
  
  
  #------------------------------------------------------------------------------
  # Fixtures
  #------------------------------------------------------------------------------
  
  def setup():
      IPluginRegistry.plugins = []
  
  
  def teardown():
      IPluginRegistry.plugins = []
  
  
  #------------------------------------------------------------------------------
  # Tests
  #------------------------------------------------------------------------------
  
  def test_plugin_registration():
      class MyPlugin(IPlugin):
          pass
  
      assert IPluginRegistry.plugins == [MyPlugin]
  
  
  def test_discover_plugins(tempdir):
      path = op.join(tempdir, 'my_plugin.py')
      contents = '''from podoc import IPlugin\nclass MyPlugin(IPlugin): pass'''
      save_text(path, contents)
      plugins = discover_plugins([tempdir])
      assert plugins
      assert plugins[0].__name__ == 'MyPlugin'
  
  
  def test_iter_plugins_dirs():
      assert 'json' in [op.basename(plugin_dir)
                        for plugin_dir in iter_plugins_dirs()]
  
  
  def test_iter_plugin_test_files():
      for plugin_dir in iter_plugins_dirs():
          if 'json' in plugin_dir:
              assert 'hello.json' in map(op.basename,
                                         iter_plugin_test_files(plugin_dir))
  
subject: Add iter_plugin_test_files() test