~blamar/+junk/openstack-api-arrrg

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/trial/test/test_plugins.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2009 Twisted Matrix Laboratories.
 
2
# See LICENSE for details.
 
3
#
 
4
# Maintainer: Jonathan Lange
 
5
 
 
6
"""
 
7
Tests for L{twisted.plugins.twisted_trial}.
 
8
"""
 
9
 
 
10
from twisted.plugin import getPlugins
 
11
from twisted.trial import unittest
 
12
from twisted.trial.itrial import IReporter
 
13
 
 
14
 
 
15
class TestPlugins(unittest.TestCase):
 
16
    """
 
17
    Tests for Trial's reporter plugins.
 
18
    """
 
19
 
 
20
    def getPluginsByLongOption(self, longOption):
 
21
        """
 
22
        Return the Trial reporter plugin with the given long option.
 
23
 
 
24
        If more than one is found, raise ValueError. If none are found, raise
 
25
        IndexError.
 
26
        """
 
27
        plugins = [
 
28
            plugin for plugin in getPlugins(IReporter)
 
29
            if plugin.longOpt == longOption]
 
30
        if len(plugins) > 1:
 
31
            raise ValueError(
 
32
                "More than one plugin found with long option %r: %r"
 
33
                % (longOption, plugins))
 
34
        return plugins[0]
 
35
 
 
36
 
 
37
    def test_subunitPlugin(self):
 
38
        """
 
39
        One of the reporter plugins is the subunit reporter plugin.
 
40
        """
 
41
        subunitPlugin = self.getPluginsByLongOption('subunit')
 
42
        self.assertEquals('Subunit Reporter', subunitPlugin.name)
 
43
        self.assertEquals('twisted.trial.reporter', subunitPlugin.module)
 
44
        self.assertEquals('subunit', subunitPlugin.longOpt)
 
45
        self.assertIdentical(None, subunitPlugin.shortOpt)
 
46
        self.assertEquals('SubunitReporter', subunitPlugin.klass)