Ejemplo n.º 1
0
 def test_run_wrong_arg(self):
     ctxt = Context(self.basedir)
     try:
         ctxt.run(1, 'http://bitten.edgewall.org/tools/sh', 'exec', {'foo':'bar'})
         self.fail("InvalidRecipeError expected")
     except InvalidRecipeError, e:
         self.failUnless("Unsupported argument 'foo'" in str(e))
Ejemplo n.º 2
0
 def test_run_wrong_arg(self):
     ctxt = Context(self.basedir)
     try:
         ctxt.run(1, 'http://bitten.edgewall.org/tools/sh', 'exec', {'foo':'bar'})
         self.fail("InvalidRecipeError expected")
     except InvalidRecipeError, e:
         self.failUnless("Unsupported argument 'foo'" in str(e))
Ejemplo n.º 3
0
    def test_attach_file_non_existing(self):
        # Verify that it raises error and that it gets logged
        ctxt = Context(self.basedir, Configuration())
        ctxt.attach(file_='nonexisting.txt',
                      description='build build')

        self.assertEquals(1, len(ctxt.output))
        self.assertEquals(Recipe.ERROR, ctxt.output[0][0])
        self.assertEquals('Failed to read file nonexisting.txt as attachment',
                            ctxt.output[0][3])
Ejemplo n.º 4
0
    def test_attach_file_build(self):
        # Verify output from attaching a file to a build
        ctxt = Context(self.basedir, Configuration())

        ctxt.attach(file_='build.txt', description='build build')
        self.assertEquals(1, len(ctxt.output))
        self.assertEquals(Recipe.ATTACH, ctxt.output[0][0])
        attach_xml = ctxt.output[0][3]
        self.assertEquals('<file resource="build" '
                          'description="build build" '
                          'filename="build.txt"/>', str(attach_xml))
Ejemplo n.º 5
0
 def setUp(self):
     self.basedir = os.path.realpath(tempfile.mkdtemp())
     self.ctxt = Context(self.basedir)
     self.summary = open(os.path.join(self.basedir, 'test-coverage.txt'),
                         'w')
     self.coverdir = os.path.join(self.basedir, 'coverage')
     os.mkdir(self.coverdir)
Ejemplo n.º 6
0
    def test_attach_file_build(self):
        # Verify output from attaching a file to a build
        ctxt = Context(self.basedir, Configuration())
        test_file = open(os.path.join(self.basedir, 'build.txt'), 'w')
        test_file.write('hello build')
        test_file.close()

        ctxt.attach(file_='build.txt', description='build build')
        self.assertEquals(1, len(ctxt.output))
        self.assertEquals(Recipe.ATTACH, ctxt.output[0][0])
        attach_xml = ctxt.output[0][3]
        self.assertEquals('<file resource="build" '
                          'description="build build" '
                          'filename="build.txt">'
                          'aGVsbG8gYnVpbGQ=\n'
                          '</file>', str(attach_xml))
Ejemplo n.º 7
0
    def test_attach_file_config(self):
        # Verify output from attaching a file to a config
        ctxt = Context(self.basedir, Configuration())
        test_file = open(os.path.join(self.basedir, 'config.txt'), 'w')
        test_file.write('hello config')
        test_file.close()

        ctxt.attach(file_='config.txt', description='config config',
                      resource='config')
        self.assertEquals(1, len(ctxt.output))
        self.assertEquals(Recipe.ATTACH, ctxt.output[0][0])
        attach_xml = ctxt.output[0][3]
        self.assertEquals('<file resource="config" '
                          'description="config config" '
                          'filename="config.txt">'
                          'aGVsbG8gY29uZmln\n'
                          '</file>', str(attach_xml))
Ejemplo n.º 8
0
    def test_vars_basedir(self):
        config = Configuration(properties={'foo.bar': 'baz'})
        ctxt = Context('%s/${path}/${foo.bar}' % os.path.realpath('/foo'),
                        config, {'path': 'bar'})

        self.assertEquals(os.path.realpath('/foo/bar/baz'),
                        os.path.realpath(ctxt.vars['basedir']))
        if os.name == 'nt':
            # Make sure paths are double-escaped
            self.failUnless('\\\\' in ctxt.vars['basedir'])
Ejemplo n.º 9
0
class PhpCodeCoverageTestCase(unittest.TestCase):

    def setUp(self):
        self.basedir = os.path.realpath(tempfile.mkdtemp())
        self.ctxt = Context(self.basedir)

    def tearDown(self):
        shutil.rmtree(self.basedir)

    def test_missing_param_file(self):
        self.assertRaises(AssertionError, phptools.coverage, self.ctxt)

    def test_sample_code_coverage(self):
        coverage_xml = file(self.ctxt.resolve('phpcoverage.xml'), 'w')
        coverage_xml.write("""<?xml version="1.0" encoding="UTF-8"?>
<snapshot methodcount="4" methodscovered="2" statementcount="11" statementscovered="5" totalcount="15" totalcovered="7">
  <package name="default" methodcount="4" methodscovered="2" statementcount="11" statementscovered="5" totalcount="15" totalcovered="7">
    <class name="Foo" methodcount="1" methodscovered="1" statementcount="7" statementscovered="3" totalcount="8" totalcovered="4">
      <sourcefile name="Foo.php" sourcefile="xxxx/Foo.php">
	  ...
      </sourcefile>
    </class>
    <class name="Foo2" methodcount="2" methodscovered="1" statementcount="4" statementscovered="2" totalcount="6" totalcovered="3">
      <sourcefile name="Foo.php" sourcefile="xxxx/Foo.php">
        ...
      </sourcefile>
    </class>
    <class name="Bar" methodcount="1" methodscovered="0" statementcount="0" statementscovered="0" totalcount="1" totalcovered="0">
      <sourcefile name="Bar.php" sourcefile="xxxx/Bar.php">
        ...
      </sourcefile>
    </class>
  </package>
</snapshot>""")
        coverage_xml.close()
        phptools.coverage(self.ctxt, file_='phpcoverage.xml')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('coverage', category)

        coverage = list(xml.children)
        self.assertEqual(3, len(coverage))
        self.assertEqual(7, coverage[0].attr['lines'])
        self.assertEqual('Foo', coverage[0].attr['name'])
        self.assert_('xxxx/Foo.php' in coverage[0].attr['file'])

        self.assertEqual(4, coverage[1].attr['lines'])
        self.assertEqual(50.0, coverage[1].attr['percentage'])
        self.assertEqual('Foo2', coverage[1].attr['name'])
        self.assert_('xxxx/Foo.php' in coverage[1].attr['file'])
        
        self.assertEqual(0, coverage[2].attr['lines'])
        self.assertEqual(100.0, coverage[2].attr['percentage'])
        self.assertEqual('Bar', coverage[2].attr['name'])
        self.assert_('xxxx/Bar.php' in coverage[2].attr['file'])
Ejemplo n.º 10
0
class PhpUnitTestCase(unittest.TestCase):

    def setUp(self):
        self.basedir = os.path.realpath(tempfile.mkdtemp())
        self.ctxt = Context(self.basedir)

    def tearDown(self):
        shutil.rmtree(self.basedir)

    def test_missing_param_file(self):
        self.assertRaises(AssertionError, phptools.phpunit, self.ctxt)

    def test_sample_unit_test_result(self):
        phpunit_xml = file(self.ctxt.resolve('phpunit.xml'), 'w')
        phpunit_xml.write("""<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="FooTest" file="FooTest.php" tests="2" failures="1" errors="0" time="0.147397">
    <testcase name="testBar" class="FooTest" time="0.122265">
      <failure message="expected same: &lt;1&gt; was not: &lt;2&gt;" type="PHPUnit2_Framework_AssertionFailedError">
      ...
</failure>
    </testcase>
    <testcase name="testBar2" class="FooTest" time="0.025132"/>
  </testsuite>
  <testsuite name="BarTest" file="BarTest.php" tests="1" failures="0" errors="0" time="0.050713">
    <testcase name="testFoo" class="BarTest" time="0.026046"/>
  </testsuite>
</testsuites>""")
        phpunit_xml.close()
        phptools.phpunit(self.ctxt, file_='phpunit.xml')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('test', category)

        tests = list(xml.children)
        self.assertEqual(3, len(tests))
        self.assertEqual('FooTest', tests[0].attr['fixture'])
        self.assertEqual('testBar', tests[0].attr['name'])
        self.assertEqual('failure', tests[0].attr['status'])
        self.assert_('FooTest.php' in tests[0].attr['file'])

        self.assertEqual('FooTest', tests[1].attr['fixture'])
        self.assertEqual('testBar2', tests[1].attr['name'])
        self.assertEqual('success', tests[1].attr['status'])

        self.assertEqual('BarTest', tests[2].attr['fixture'])
        self.assertEqual('testFoo', tests[2].attr['name'])
        self.assertEqual('success', tests[2].attr['status'])
Ejemplo n.º 11
0
class PhpUnitTestCase(unittest.TestCase):
    def setUp(self):
        self.basedir = os.path.realpath(tempfile.mkdtemp())
        self.ctxt = Context(self.basedir)

    def tearDown(self):
        shutil.rmtree(self.basedir)

    def test_missing_param_file(self):
        self.assertRaises(AssertionError, phptools.phpunit, self.ctxt)

    def test_sample_unit_test_result(self):
        phpunit_xml = file(self.ctxt.resolve('phpunit.xml'), 'w')
        phpunit_xml.write("""<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="FooTest" file="FooTest.php" tests="2" failures="1" errors="0" time="0.147397">
    <testcase name="testBar" class="FooTest" time="0.122265">
      <failure message="expected same: &lt;1&gt; was not: &lt;2&gt;" type="PHPUnit2_Framework_AssertionFailedError">
      ...
</failure>
    </testcase>
    <testcase name="testBar2" class="FooTest" time="0.025132"/>
  </testsuite>
  <testsuite name="BarTest" file="BarTest.php" tests="1" failures="0" errors="0" time="0.050713">
    <testcase name="testFoo" class="BarTest" time="0.026046"/>
  </testsuite>
</testsuites>""")
        phpunit_xml.close()
        phptools.phpunit(self.ctxt, file_='phpunit.xml')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('test', category)

        tests = list(xml.children)
        self.assertEqual(3, len(tests))
        self.assertEqual('FooTest', tests[0].attr['fixture'])
        self.assertEqual('testBar', tests[0].attr['name'])
        self.assertEqual('failure', tests[0].attr['status'])
        self.assert_('FooTest.php' in tests[0].attr['file'])

        self.assertEqual('FooTest', tests[1].attr['fixture'])
        self.assertEqual('testBar2', tests[1].attr['name'])
        self.assertEqual('success', tests[1].attr['status'])

        self.assertEqual('BarTest', tests[2].attr['fixture'])
        self.assertEqual('testFoo', tests[2].attr['name'])
        self.assertEqual('success', tests[2].attr['status'])
Ejemplo n.º 12
0
 def setUp(self):
     self.basedir = os.path.realpath(tempfile.mkdtemp())
     self.ctxt = Context(self.basedir)
     self.summary = open(os.path.join(self.basedir, '.figleaf'), 'w')
Ejemplo n.º 13
0
class FigleafTestCase(unittest.TestCase):
    def setUp(self):
        self.basedir = os.path.realpath(tempfile.mkdtemp())
        self.ctxt = Context(self.basedir)
        self.summary = open(os.path.join(self.basedir, '.figleaf'), 'w')

    def tearDown(self):
        shutil.rmtree(self.basedir)

    def _create_file(self, *path):
        filename = os.path.join(self.basedir, *path)
        dirname = os.path.dirname(filename)
        os.makedirs(dirname)
        fd = file(filename, 'w')
        fd.close()
        return filename[len(self.basedir) + 1:]

    def test_missing_param_summary(self):
        self.summary.close()
        self.assertRaises(AssertionError, pythontools.coverage, self.ctxt)

    def test_empty_summary(self):
        pickle.dump({}, self.summary)
        self.summary.close()
        pythontools.figleaf(self.ctxt,
                            summary=self.summary.name,
                            include='*.py')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('coverage', category)
        self.assertEqual(0, len(xml.children))

    def test_missing_coverage_file(self):
        self.summary.close()
        pythontools.figleaf(self.ctxt,
                            summary='non-existant-file',
                            include='*.py')
        self.assertEqual([], self.ctxt.output)

    def test_summary_with_absolute_path(self):
        filename = os.sep.join([self.ctxt.basedir, 'test', 'module.py'])
        pickle.dump({
            filename: set([1, 4, 5]),
        }, self.summary)
        self.summary.close()
        sourcefile = self.ctxt.resolve(self._create_file('test', 'module.py'))
        open(sourcefile, 'w').write("if foo: # line 1\n"
                                    "  print 'uncovered' # line 2\n"
                                    "else: # line 3 (uninteresting)\n"
                                    "  print 'covered' # line 4\n"
                                    "print 'covered' # line 6\n")
        pythontools.figleaf(self.ctxt,
                            summary=self.summary.name,
                            include='test/*')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('coverage', category)
        self.assertEqual(1, len(xml.children))
        child = xml.children[0]
        self.assertEqual('coverage', child.name)
        self.assertEqual('test.module', child.attr['name'])
        self.assertEqual('test/module.py', child.attr['file'])
        self.assertEqual(75, child.attr['percentage'])
        self.assertEqual(4, child.attr['lines'])
        self.assertEqual('1 0 - 1 1', child.attr['line_hits'])

    def test_summary_with_non_covered_file(self):
        pickle.dump({}, self.summary)
        self.summary.close()
        sourcefile = self.ctxt.resolve(self._create_file('test', 'module.py'))
        open(sourcefile, 'w').write("print 'line 1'\n"
                                    "print 'line 2'\n"
                                    "print 'line 3'\n"
                                    "print 'line 4'\n"
                                    "print 'line 5'\n")
        pythontools.figleaf(self.ctxt,
                            summary=self.summary.name,
                            include='test/*')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('coverage', category)
        self.assertEqual(1, len(xml.children))
        child = xml.children[0]
        self.assertEqual('coverage', child.name)
        self.assertEqual('test.module', child.attr['name'])
        self.assertEqual('test/module.py', child.attr['file'])
        self.assertEqual(0, child.attr['percentage'])
        self.assertEqual(5, child.attr['lines'])

    def test_summary_with_non_python_files(self):
        "Figleaf coverage reports should not include files that do not end in .py"
        pickle.dump({}, self.summary)
        self.summary.close()
        sourcefile = self.ctxt.resolve(
            self._create_file('test', 'document.txt'))
        open(sourcefile, 'w').write("\n")
        pythontools.figleaf(self.ctxt,
                            summary=self.summary.name,
                            include='test/*')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('coverage', category)
        self.assertEqual(0, len(xml.children))
Ejemplo n.º 14
0
class TransformTestCase(unittest.TestCase):

    def setUp(self):
        self.basedir = os.path.realpath(tempfile.mkdtemp())
        self.ctxt = Context(self.basedir)

    def tearDown(self):
        shutil.rmtree(self.basedir)

    def test_transform_no_src(self):
        self.assertRaises(AssertionError, xmltools.transform, self.ctxt)

    def test_transform_no_dest(self):
        self.assertRaises(AssertionError, xmltools.transform, self.ctxt,
                          src='src.xml')

    def test_transform_no_stylesheet(self):
        self.assertRaises(AssertionError, xmltools.transform, self.ctxt,
                          src='src.xml', dest='dest.xml')

    def test_transform(self):
        src_file = file(self.ctxt.resolve('src.xml'), 'w')
        try:
            src_file.write("""<doc>
<title>Document Title</title>
<section>
<title>Section Title</title>
<para>This is a test.</para>
<note>This is a note.</note>
</section>
</doc>
""")
        finally:
            src_file.close()

        style_file = file(self.ctxt.resolve('style.xsl'), 'w')
        try:
            style_file.write("""<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/TR/xhtml1/strict">
 <xsl:template match="doc">
  <html>
   <head>
    <title><xsl:value-of select="title"/></title>
   </head>
   <body>
    <xsl:apply-templates/>
   </body>
  </html>
 </xsl:template>
 <xsl:template match="doc/title">
  <h1><xsl:apply-templates/></h1>
 </xsl:template>
 <xsl:template match="section/title">
  <h2><xsl:apply-templates/></h2>
 </xsl:template>
 <xsl:template match="para">
  <p><xsl:apply-templates/></p>
 </xsl:template>
 <xsl:template match="note">
  <p class="note"><b>NOTE: </b><xsl:apply-templates/></p>
 </xsl:template>
</xsl:stylesheet>
""")
        finally:
            style_file.close()

        xmltools.transform(self.ctxt, src='src.xml', dest='dest.xml',
                           stylesheet='style.xsl')

        dest_file = file(self.ctxt.resolve('dest.xml'))
        try:
            dest = xmlio.parse(dest_file)
        finally:
            dest_file.close()

        self.assertEqual('html', dest.name)
        self.assertEqual('http://www.w3.org/TR/xhtml1/strict', dest.namespace)
        children = list(dest.children())
        self.assertEqual(2, len(children))
        self.assertEqual('head', children[0].name)
        head_children = list(children[0].children())
        self.assertEqual(1, len(head_children))
        self.assertEqual('title', head_children[0].name)
        self.assertEqual('Document Title', head_children[0].gettext())
        self.assertEqual('body', children[1].name)
        body_children = list(children[1].children())
        self.assertEqual(4, len(body_children))
        self.assertEqual('h1', body_children[0].name)
        self.assertEqual('Document Title', body_children[0].gettext())
        self.assertEqual('h2', body_children[1].name)
        self.assertEqual('Section Title', body_children[1].gettext())
        self.assertEqual('p', body_children[2].name)
        self.assertEqual('This is a test.', body_children[2].gettext())
        self.assertEqual('p', body_children[3].name)
        self.assertEqual('note', body_children[3].attr['class'])
        self.assertEqual('This is a note.', body_children[3].gettext())
Ejemplo n.º 15
0
class PhpCodeCoverageTestCase(unittest.TestCase):
    def setUp(self):
        self.basedir = os.path.realpath(tempfile.mkdtemp())
        self.ctxt = Context(self.basedir)

    def tearDown(self):
        shutil.rmtree(self.basedir)

    def test_missing_param_file(self):
        self.assertRaises(AssertionError, phptools.coverage, self.ctxt)

    def test_sample_phing_code_coverage(self):
        coverage_xml = file(self.ctxt.resolve('phpcoverage.xml'), 'w')
        coverage_xml.write("""<?xml version="1.0" encoding="UTF-8"?>
<snapshot methodcount="4" methodscovered="2" statementcount="11" statementscovered="5" totalcount="15" totalcovered="7">
  <package name="default" methodcount="4" methodscovered="2" statementcount="11" statementscovered="5" totalcount="15" totalcovered="7">
    <class name="Foo" methodcount="1" methodscovered="1" statementcount="7" statementscovered="3" totalcount="8" totalcovered="4">
      <sourcefile name="Foo.php" sourcefile="xxxx/Foo.php">
        ...
      </sourcefile>
    </class>
    <class name="Foo2" methodcount="2" methodscovered="1" statementcount="4" statementscovered="2" totalcount="6" totalcovered="3">
      <sourcefile name="Foo.php" sourcefile="xxxx/Foo.php">
        ...
      </sourcefile>
    </class>
    <class name="Bar" methodcount="1" methodscovered="0" statementcount="0" statementscovered="0" totalcount="1" totalcovered="0">
      <sourcefile name="Bar.php" sourcefile="xxxx/Bar.php">
        ...
      </sourcefile>
    </class>
  </package>
</snapshot>""")
        coverage_xml.close()
        phptools.coverage(self.ctxt, file_='phpcoverage.xml')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('coverage', category)

        coverage = list(xml.children)
        self.assertEqual(3, len(coverage))
        self.assertEqual(7, coverage[0].attr['lines'])
        self.assertEqual('Foo', coverage[0].attr['name'])
        self.assert_('xxxx/Foo.php' in coverage[0].attr['file'])

        self.assertEqual(4, coverage[1].attr['lines'])
        self.assertEqual(50.0, coverage[1].attr['percentage'])
        self.assertEqual('Foo2', coverage[1].attr['name'])
        self.assert_('xxxx/Foo.php' in coverage[1].attr['file'])

        self.assertEqual(0, coverage[2].attr['lines'])
        self.assertEqual(100.0, coverage[2].attr['percentage'])
        self.assertEqual('Bar', coverage[2].attr['name'])
        self.assert_('xxxx/Bar.php' in coverage[2].attr['file'])

    def test_sample_phpunit_code_coverage(self):
        coverage_xml = file(self.ctxt.resolve('phpcoverage.xml'), 'w')
        coverage_xml.write(
            """<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1248813201" phpunit="3.3.17">
  <project name="All Tests" timestamp="1248813201">
    <file name="%s/Foo/classes/Foo.php">
      <class name="Foo" namespace="global">
        <metrics methods="0" coveredmethods="0" statements="0"
          coveredstatements="0" elements="0" coveredelements="0"/>
      </class>
      <line num="3" type="stmt" count="1"/>
      <line num="6" type="stmt" count="1"/>
      <metrics loc="5" ncloc="3" classes="1" methods="0" coveredmethods="0"
        statements="2" coveredstatements="2" elements="2" coveredelements="2"/>
    </file>
    <file name="%s/Foo/tests/environment.config.php">
      <line num="0" type="stmt" count="2"/>
      <line num="4" type="stmt" count="2"/>
      <line num="5" type="stmt" count="2"/>
      <metrics loc="6" ncloc="6" classes="0" methods="0" coveredmethods="0"
        statements="3" coveredstatements="3" elements="3" coveredelements="3"/>
    </file>
    <file name="%s/Foo/tests/Foo/AllTests.php">
      <class name="All_Foo_Tests" namespace="global" fullPackage="All.Foo">
        <metrics methods="2" coveredmethods="0" statements="4"
          coveredstatements="0" elements="6" coveredelements="0"/>
      </class>
      <line num="7" type="method" count="0"/>
      <line num="9" type="stmt" count="0"/>
      <line num="10" type="stmt" count="0"/>
      <line num="12" type="method" count="0"/>
      <line num="14" type="stmt" count="0"/>
      <line num="15" type="stmt" count="0"/>
      <line num="16" type="stmt" count="0"/>
      <metrics loc="19" ncloc="19" classes="1" methods="2" coveredmethods="0"
        statements="5" coveredstatements="0" elements="7" coveredelements="0"/>
    </file>
    <file name="%s/Foo/tests/AllTests.php">
      <class name="AllTests" namespace="global">
        <metrics methods="2" coveredmethods="0" statements="5"
          coveredstatements="0" elements="7" coveredelements="0"/>
      </class>
      <line num="8" type="method" count="0"/>
      <line num="10" type="stmt" count="0"/>
      <line num="11" type="stmt" count="0"/>
      <line num="13" type="method" count="0"/>
      <line num="15" type="stmt" count="0"/>
      <line num="16" type="stmt" count="0"/>
      <line num="17" type="stmt" count="0"/>
      <line num="18" type="stmt" count="0"/>
      <metrics loc="22" ncloc="22" classes="1" methods="2" coveredmethods="0"
        statements="6" coveredstatements="0" elements="8" coveredelements="0"/>
    </file>
    <file name="%s/Foo/tests/Bar/AllTests.php">
      <class name="All_Bar_Tests" namespace="global" fullPackage="All.Bar">
        <metrics methods="2" coveredmethods="0" statements="5"
          coveredstatements="0" elements="7" coveredelements="0"/>
      </class>
      <line num="8" type="method" count="0"/>
      <line num="10" type="stmt" count="0"/>
      <line num="11" type="stmt" count="0"/>
      <line num="13" type="method" count="0"/>
      <line num="15" type="stmt" count="0"/>
      <line num="16" type="stmt" count="0"/>
      <line num="17" type="stmt" count="0"/>
      <line num="18" type="stmt" count="0"/>
      <metrics loc="20" ncloc="20" classes="1" methods="2" coveredmethods="0"
        statements="6" coveredstatements="0" elements="8" coveredelements="0"/>
    </file>
    <file name="%s/Foo/tests/Bar/Nested/AllTests.php">
      <class name="All_Bar_Nested_Tests" namespace="global" fullPackage="All.Bar.Nested">
        <metrics methods="2" coveredmethods="0" statements="5"
          coveredstatements="0" elements="7" coveredelements="0"/>
      </class>
      <line num="8" type="method" count="0"/>
      <line num="10" type="stmt" count="0"/>
      <line num="11" type="stmt" count="0"/>
      <line num="13" type="method" count="0"/>
      <line num="15" type="stmt" count="0"/>
      <line num="16" type="stmt" count="0"/>
      <line num="17" type="stmt" count="0"/>
      <line num="18" type="stmt" count="0"/>
      <metrics loc="21" ncloc="21" classes="1" methods="2" coveredmethods="0"
        statements="6" coveredstatements="0" elements="8" coveredelements="0"/>
    </file>
    <file name="Foo/classes/Bar.php">
      <class name="Bar" namespace="global">
        <metrics methods="0" coveredmethods="0" statements="0"
          coveredstatements="0" elements="0" coveredelements="0"/>
      </class>
      <line num="3" type="stmt" count="1"/>
      <line num="6" type="stmt" count="1"/>
      <metrics loc="5" ncloc="3" classes="1" methods="0" coveredmethods="0"
        statements="2" coveredstatements="2" elements="2" coveredelements="2"/>
    </file>
    <metrics files="7" loc="98" ncloc="94" classes="6" methods="8" coveredmethods="0"
      statements="30" coveredstatements="7" elements="38" coveredelements="7"/>
  </project>
</coverage>""" %
            ((self.basedir, ) * 6))  # One relative path, remaining is absolute
        coverage_xml.close()
        phptools.coverage(self.ctxt, file_='phpcoverage.xml')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('coverage', category)

        coverage = list(xml.children)
        self.assertEqual(6, len(coverage))

        self.assertEqual(27, sum([int(c.attr['lines']) for c in coverage]))
        self.assertEqual([
            'Foo', 'All_Foo_Tests', 'AllTests', 'All_Bar_Tests',
            'All_Bar_Nested_Tests', 'Bar'
        ], [c.attr['name'] for c in coverage])
        self.assertEqual([
            'Foo/classes/Foo.php', 'Foo/tests/Foo/AllTests.php',
            'Foo/tests/AllTests.php', 'Foo/tests/Bar/AllTests.php',
            'Foo/tests/Bar/Nested/AllTests.php', 'Foo/classes/Bar.php'
        ], [c.attr['file'] for c in coverage])
        self.assertEqual([100, 0, 0, 0, 0, 100],
                         [c.attr['percentage'] for c in coverage])
Ejemplo n.º 16
0
class FigleafTestCase(unittest.TestCase):

    def setUp(self):
        self.basedir = os.path.realpath(tempfile.mkdtemp())
        self.ctxt = Context(self.basedir)
        self.summary = open(os.path.join(self.basedir, '.figleaf'), 'w')

    def tearDown(self):
        shutil.rmtree(self.basedir)

    def _create_file(self, *path):
        filename = os.path.join(self.basedir, *path)
        dirname = os.path.dirname(filename)
        os.makedirs(dirname)
        fd = file(filename, 'w')
        fd.close()
        return filename[len(self.basedir) + 1:]

    def test_missing_param_summary(self):
        self.summary.close()
        self.assertRaises(AssertionError, pythontools.coverage, self.ctxt)

    def test_empty_summary(self):
        pickle.dump({}, self.summary)
        self.summary.close()
        pythontools.figleaf(self.ctxt, summary=self.summary.name, include='*.py')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('coverage', category)
        self.assertEqual(0, len(xml.children))

    def test_missing_coverage_file(self):
        self.summary.close()
        pythontools.figleaf(self.ctxt, summary='non-existant-file', include='*.py')
        self.assertEqual([], self.ctxt.output)

    def test_summary_with_absolute_path(self):
        filename = os.sep.join([self.ctxt.basedir, 'test', 'module.py'])
        pickle.dump({
            filename: set([1, 4, 5]),
        }, self.summary)
        self.summary.close()
        sourcefile = self.ctxt.resolve(self._create_file('test', 'module.py'))
        open(sourcefile, 'w').write(
            "if foo: # line 1\n"
            "  print 'uncovered' # line 2\n"
            "else: # line 3 (uninteresting)\n"
            "  print 'covered' # line 4\n"
            "print 'covered' # line 6\n"
        )
        pythontools.figleaf(self.ctxt, summary=self.summary.name,
                            include='test/*')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('coverage', category)
        self.assertEqual(1, len(xml.children))
        child = xml.children[0]
        self.assertEqual('coverage', child.name)
        self.assertEqual('test.module', child.attr['name'])
        self.assertEqual('test/module.py', child.attr['file'])
        self.assertEqual(75, child.attr['percentage'])
        self.assertEqual(4, child.attr['lines'])
        self.assertEqual('1 0 - 1 1', child.attr['line_hits'])

    def test_summary_with_non_covered_file(self):
        pickle.dump({}, self.summary)
        self.summary.close()
        sourcefile = self.ctxt.resolve(self._create_file('test', 'module.py'))
        open(sourcefile, 'w').write(
            "print 'line 1'\n"
            "print 'line 2'\n"
            "print 'line 3'\n"
            "print 'line 4'\n"
            "print 'line 5'\n"
        )
        pythontools.figleaf(self.ctxt, summary=self.summary.name,
                            include='test/*')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('coverage', category)
        self.assertEqual(1, len(xml.children))
        child = xml.children[0]
        self.assertEqual('coverage', child.name)
        self.assertEqual('test.module', child.attr['name'])
        self.assertEqual('test/module.py', child.attr['file'])
        self.assertEqual(0, child.attr['percentage'])
        self.assertEqual(5, child.attr['lines'])

    def test_summary_with_non_python_files(self):
        "Figleaf coverage reports should not include files that do not end in .py"
        pickle.dump({}, self.summary)
        self.summary.close()
        sourcefile = self.ctxt.resolve(self._create_file('test', 'document.txt'))
        open(sourcefile, 'w').write("\n")
        pythontools.figleaf(self.ctxt, summary=self.summary.name,
                            include='test/*')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('coverage', category)
        self.assertEqual(0, len(xml.children))
Ejemplo n.º 17
0
 def setUp(self):
     self.basedir = os.path.realpath(tempfile.mkdtemp())
     self.ctxt = Context(self.basedir)
     self.summary = open(os.path.join(self.basedir, '.figleaf'), 'w')
Ejemplo n.º 18
0
class CppUnitTestCase(unittest.TestCase):
    def setUp(self):
        self.basedir = os.path.realpath(tempfile.mkdtemp())
        self.ctxt = Context(self.basedir)

    def tearDown(self):
        shutil.rmtree(self.basedir)

    def test_missing_param_file(self):
        self.assertRaises(AssertionError, ctools.cppunit, self.ctxt)

    def test_empty_summary(self):
        cppunit_xml = file(self.ctxt.resolve('cppunit.xml'), 'w')
        cppunit_xml.write("""<?xml version="1.0" encoding='utf-8' ?>
<TestRun>
  <FailedTests>
    <FailedTest id="2">
      <Name>HelloTest::secondTest</Name>
      <FailureType>Assertion</FailureType>
      <Location>
        <File>HelloTest.cxx</File>
        <Line>95</Line>
      </Location>
      <Message>assertion failed
- Expression: 2 == 3
</Message>
    </FailedTest>
  </FailedTests>
  <SuccessfulTests>
    <Test id="1">
      <Name>HelloTest::firstTest</Name>
    </Test>
    <Test id="3">
      <Name>HelloTest::thirdTest</Name>
    </Test>
  </SuccessfulTests>
  <Statistics>
    <Tests>3</Tests>
    <FailuresTotal>1</FailuresTotal>
    <Errors>0</Errors>
    <Failures>1</Failures>
  </Statistics>
</TestRun>""")
        cppunit_xml.close()
        ctools.cppunit(self.ctxt, file_='cppunit.xml')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('test', category)

        tests = list(xml.children)
        self.assertEqual(3, len(tests))
        self.assertEqual('HelloTest', tests[0].attr['fixture'])
        self.assertEqual('secondTest', tests[0].attr['name'])
        self.assertEqual('failure', tests[0].attr['status'])
        self.assertEqual('HelloTest.cxx', tests[0].attr['file'])
        self.assertEqual('95', tests[0].attr['line'])

        self.assertEqual('HelloTest', tests[1].attr['fixture'])
        self.assertEqual('firstTest', tests[1].attr['name'])
        self.assertEqual('success', tests[1].attr['status'])

        self.assertEqual('HelloTest', tests[2].attr['fixture'])
        self.assertEqual('thirdTest', tests[2].attr['name'])
        self.assertEqual('success', tests[2].attr['status'])
Ejemplo n.º 19
0
 def setUp(self):
     self.basedir = os.path.realpath(tempfile.mkdtemp())
     self.ctxt = Context(self.basedir)
Ejemplo n.º 20
0
class TransformTestCase(unittest.TestCase):
    def setUp(self):
        self.basedir = os.path.realpath(tempfile.mkdtemp())
        self.ctxt = Context(self.basedir)

    def tearDown(self):
        shutil.rmtree(self.basedir)

    def test_transform_no_src(self):
        self.assertRaises(AssertionError, xmltools.transform, self.ctxt)

    def test_transform_no_dest(self):
        self.assertRaises(AssertionError, xmltools.transform, self.ctxt, src="src.xml")

    def test_transform_no_stylesheet(self):
        self.assertRaises(AssertionError, xmltools.transform, self.ctxt, src="src.xml", dest="dest.xml")

    def test_transform(self):
        src_file = file(self.ctxt.resolve("src.xml"), "w")
        try:
            src_file.write(
                """<doc>
<title>Document Title</title>
<section>
<title>Section Title</title>
<para>This is a test.</para>
<note>This is a note.</note>
</section>
</doc>
"""
            )
        finally:
            src_file.close()

        style_file = file(self.ctxt.resolve("style.xsl"), "w")
        try:
            style_file.write(
                """<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/TR/xhtml1/strict">
 <xsl:template match="doc">
  <html>
   <head>
    <title><xsl:value-of select="title"/></title>
   </head>
   <body>
    <xsl:apply-templates/>
   </body>
  </html>
 </xsl:template>
 <xsl:template match="doc/title">
  <h1><xsl:apply-templates/></h1>
 </xsl:template>
 <xsl:template match="section/title">
  <h2><xsl:apply-templates/></h2>
 </xsl:template>
 <xsl:template match="para">
  <p><xsl:apply-templates/></p>
 </xsl:template>
 <xsl:template match="note">
  <p class="note"><b>NOTE: </b><xsl:apply-templates/></p>
 </xsl:template>
</xsl:stylesheet>
"""
            )
        finally:
            style_file.close()

        xmltools.transform(self.ctxt, src="src.xml", dest="dest.xml", stylesheet="style.xsl")

        dest_file = file(self.ctxt.resolve("dest.xml"))
        try:
            dest = xmlio.parse(dest_file)
        finally:
            dest_file.close()

        self.assertEqual("html", dest.name)
        self.assertEqual("http://www.w3.org/TR/xhtml1/strict", dest.namespace)
        children = list(dest.children())
        self.assertEqual(2, len(children))
        self.assertEqual("head", children[0].name)
        head_children = list(children[0].children())
        self.assertEqual(1, len(head_children))
        self.assertEqual("title", head_children[0].name)
        self.assertEqual("Document Title", head_children[0].gettext())
        self.assertEqual("body", children[1].name)
        body_children = list(children[1].children())
        self.assertEqual(4, len(body_children))
        self.assertEqual("h1", body_children[0].name)
        self.assertEqual("Document Title", body_children[0].gettext())
        self.assertEqual("h2", body_children[1].name)
        self.assertEqual("Section Title", body_children[1].gettext())
        self.assertEqual("p", body_children[2].name)
        self.assertEqual("This is a test.", body_children[2].gettext())
        self.assertEqual("p", body_children[3].name)
        self.assertEqual("note", body_children[3].attr["class"])
        self.assertEqual("This is a note.", body_children[3].gettext())
Ejemplo n.º 21
0
 def setUp(self):
     self.basedir = os.path.realpath(tempfile.mkdtemp())
     self.ctxt = Context(self.basedir)
     self.results_xml = open(os.path.join(self.basedir, 'test-results.xml'),
                             'w')
Ejemplo n.º 22
0
class CppUnitTestCase(unittest.TestCase):

    def setUp(self):
        self.basedir = os.path.realpath(tempfile.mkdtemp())
        self.ctxt = Context(self.basedir)

    def tearDown(self):
        shutil.rmtree(self.basedir)

    def test_missing_param_file(self):
        self.assertRaises(AssertionError, ctools.cppunit, self.ctxt)

    def test_empty_summary(self):
        cppunit_xml = file(self.ctxt.resolve('cppunit.xml'), 'w')
        cppunit_xml.write("""<?xml version="1.0" encoding='utf-8' ?>
<TestRun>
  <FailedTests>
    <FailedTest id="2">
      <Name>HelloTest::secondTest</Name>
      <FailureType>Assertion</FailureType>
      <Location>
        <File>HelloTest.cxx</File>
        <Line>95</Line>
      </Location>
      <Message>assertion failed
- Expression: 2 == 3
</Message>
    </FailedTest>
  </FailedTests>
  <SuccessfulTests>
    <Test id="1">
      <Name>HelloTest::firstTest</Name>
    </Test>
    <Test id="3">
      <Name>HelloTest::thirdTest</Name>
    </Test>
  </SuccessfulTests>
  <Statistics>
    <Tests>3</Tests>
    <FailuresTotal>1</FailuresTotal>
    <Errors>0</Errors>
    <Failures>1</Failures>
  </Statistics>
</TestRun>""")
        cppunit_xml.close()
        ctools.cppunit(self.ctxt, file_='cppunit.xml')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('test', category)

        tests = list(xml.children)
        self.assertEqual(3, len(tests))
        self.assertEqual('HelloTest', tests[0].attr['fixture'])
        self.assertEqual('secondTest', tests[0].attr['name'])
        self.assertEqual('failure', tests[0].attr['status'])
        self.assertEqual('HelloTest.cxx', tests[0].attr['file'])
        self.assertEqual('95', tests[0].attr['line'])

        self.assertEqual('HelloTest', tests[1].attr['fixture'])
        self.assertEqual('firstTest', tests[1].attr['name'])
        self.assertEqual('success', tests[1].attr['status'])

        self.assertEqual('HelloTest', tests[2].attr['fixture'])
        self.assertEqual('thirdTest', tests[2].attr['name'])
        self.assertEqual('success', tests[2].attr['status'])
Ejemplo n.º 23
0
 def setUp(self):
     self.basedir = os.path.realpath(tempfile.mkdtemp())
     self.ctxt = Context(self.basedir)
Ejemplo n.º 24
0
class PhpCodeCoverageTestCase(unittest.TestCase):

    def setUp(self):
        self.basedir = os.path.realpath(tempfile.mkdtemp())
        self.ctxt = Context(self.basedir)

    def tearDown(self):
        shutil.rmtree(self.basedir)

    def test_missing_param_file(self):
        self.assertRaises(AssertionError, phptools.coverage, self.ctxt)

    def test_sample_phing_code_coverage(self):
        coverage_xml = file(self.ctxt.resolve('phpcoverage.xml'), 'w')
        coverage_xml.write("""<?xml version="1.0" encoding="UTF-8"?>
<snapshot methodcount="4" methodscovered="2" statementcount="11" statementscovered="5" totalcount="15" totalcovered="7">
  <package name="default" methodcount="4" methodscovered="2" statementcount="11" statementscovered="5" totalcount="15" totalcovered="7">
    <class name="Foo" methodcount="1" methodscovered="1" statementcount="7" statementscovered="3" totalcount="8" totalcovered="4">
      <sourcefile name="Foo.php" sourcefile="xxxx/Foo.php">
        ...
      </sourcefile>
    </class>
    <class name="Foo2" methodcount="2" methodscovered="1" statementcount="4" statementscovered="2" totalcount="6" totalcovered="3">
      <sourcefile name="Foo.php" sourcefile="xxxx/Foo.php">
        ...
      </sourcefile>
    </class>
    <class name="Bar" methodcount="1" methodscovered="0" statementcount="0" statementscovered="0" totalcount="1" totalcovered="0">
      <sourcefile name="Bar.php" sourcefile="xxxx/Bar.php">
        ...
      </sourcefile>
    </class>
  </package>
</snapshot>""")
        coverage_xml.close()
        phptools.coverage(self.ctxt, file_='phpcoverage.xml')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('coverage', category)

        coverage = list(xml.children)
        self.assertEqual(3, len(coverage))
        self.assertEqual(7, coverage[0].attr['lines'])
        self.assertEqual('Foo', coverage[0].attr['name'])
        self.assert_('xxxx/Foo.php' in coverage[0].attr['file'])

        self.assertEqual(4, coverage[1].attr['lines'])
        self.assertEqual(50.0, coverage[1].attr['percentage'])
        self.assertEqual('Foo2', coverage[1].attr['name'])
        self.assert_('xxxx/Foo.php' in coverage[1].attr['file'])
        
        self.assertEqual(0, coverage[2].attr['lines'])
        self.assertEqual(100.0, coverage[2].attr['percentage'])
        self.assertEqual('Bar', coverage[2].attr['name'])
        self.assert_('xxxx/Bar.php' in coverage[2].attr['file'])

    def test_sample_phpunit_code_coverage(self):
        coverage_xml = file(self.ctxt.resolve('phpcoverage.xml'), 'w')
        coverage_xml.write("""<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1248813201" phpunit="3.3.17">
  <project name="All Tests" timestamp="1248813201">
    <file name="%s/Foo/classes/Foo.php">
      <class name="Foo" namespace="global">
        <metrics methods="0" coveredmethods="0" statements="0"
          coveredstatements="0" elements="0" coveredelements="0"/>
      </class>
      <line num="3" type="stmt" count="1"/>
      <line num="6" type="stmt" count="1"/>
      <metrics loc="5" ncloc="3" classes="1" methods="0" coveredmethods="0"
        statements="2" coveredstatements="2" elements="2" coveredelements="2"/>
    </file>
    <file name="%s/Foo/tests/environment.config.php">
      <line num="0" type="stmt" count="2"/>
      <line num="4" type="stmt" count="2"/>
      <line num="5" type="stmt" count="2"/>
      <metrics loc="6" ncloc="6" classes="0" methods="0" coveredmethods="0"
        statements="3" coveredstatements="3" elements="3" coveredelements="3"/>
    </file>
    <file name="%s/Foo/tests/Foo/AllTests.php">
      <class name="All_Foo_Tests" namespace="global" fullPackage="All.Foo">
        <metrics methods="2" coveredmethods="0" statements="4"
          coveredstatements="0" elements="6" coveredelements="0"/>
      </class>
      <line num="7" type="method" count="0"/>
      <line num="9" type="stmt" count="0"/>
      <line num="10" type="stmt" count="0"/>
      <line num="12" type="method" count="0"/>
      <line num="14" type="stmt" count="0"/>
      <line num="15" type="stmt" count="0"/>
      <line num="16" type="stmt" count="0"/>
      <metrics loc="19" ncloc="19" classes="1" methods="2" coveredmethods="0"
        statements="5" coveredstatements="0" elements="7" coveredelements="0"/>
    </file>
    <file name="%s/Foo/tests/AllTests.php">
      <class name="AllTests" namespace="global">
        <metrics methods="2" coveredmethods="0" statements="5"
          coveredstatements="0" elements="7" coveredelements="0"/>
      </class>
      <line num="8" type="method" count="0"/>
      <line num="10" type="stmt" count="0"/>
      <line num="11" type="stmt" count="0"/>
      <line num="13" type="method" count="0"/>
      <line num="15" type="stmt" count="0"/>
      <line num="16" type="stmt" count="0"/>
      <line num="17" type="stmt" count="0"/>
      <line num="18" type="stmt" count="0"/>
      <metrics loc="22" ncloc="22" classes="1" methods="2" coveredmethods="0"
        statements="6" coveredstatements="0" elements="8" coveredelements="0"/>
    </file>
    <file name="%s/Foo/tests/Bar/AllTests.php">
      <class name="All_Bar_Tests" namespace="global" fullPackage="All.Bar">
        <metrics methods="2" coveredmethods="0" statements="5"
          coveredstatements="0" elements="7" coveredelements="0"/>
      </class>
      <line num="8" type="method" count="0"/>
      <line num="10" type="stmt" count="0"/>
      <line num="11" type="stmt" count="0"/>
      <line num="13" type="method" count="0"/>
      <line num="15" type="stmt" count="0"/>
      <line num="16" type="stmt" count="0"/>
      <line num="17" type="stmt" count="0"/>
      <line num="18" type="stmt" count="0"/>
      <metrics loc="20" ncloc="20" classes="1" methods="2" coveredmethods="0"
        statements="6" coveredstatements="0" elements="8" coveredelements="0"/>
    </file>
    <file name="%s/Foo/tests/Bar/Nested/AllTests.php">
      <class name="All_Bar_Nested_Tests" namespace="global" fullPackage="All.Bar.Nested">
        <metrics methods="2" coveredmethods="0" statements="5"
          coveredstatements="0" elements="7" coveredelements="0"/>
      </class>
      <line num="8" type="method" count="0"/>
      <line num="10" type="stmt" count="0"/>
      <line num="11" type="stmt" count="0"/>
      <line num="13" type="method" count="0"/>
      <line num="15" type="stmt" count="0"/>
      <line num="16" type="stmt" count="0"/>
      <line num="17" type="stmt" count="0"/>
      <line num="18" type="stmt" count="0"/>
      <metrics loc="21" ncloc="21" classes="1" methods="2" coveredmethods="0"
        statements="6" coveredstatements="0" elements="8" coveredelements="0"/>
    </file>
    <file name="Foo/classes/Bar.php">
      <class name="Bar" namespace="global">
        <metrics methods="0" coveredmethods="0" statements="0"
          coveredstatements="0" elements="0" coveredelements="0"/>
      </class>
      <line num="3" type="stmt" count="1"/>
      <line num="6" type="stmt" count="1"/>
      <metrics loc="5" ncloc="3" classes="1" methods="0" coveredmethods="0"
        statements="2" coveredstatements="2" elements="2" coveredelements="2"/>
    </file>
    <metrics files="7" loc="98" ncloc="94" classes="6" methods="8" coveredmethods="0"
      statements="30" coveredstatements="7" elements="38" coveredelements="7"/>
  </project>
</coverage>""" % ((self.basedir,)*6)) # One relative path, remaining is absolute
        coverage_xml.close()
        phptools.coverage(self.ctxt, file_='phpcoverage.xml')
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.REPORT, type)
        self.assertEqual('coverage', category)

        coverage = list(xml.children)
        self.assertEqual(6, len(coverage))

        self.assertEqual(27, sum([int(c.attr['lines']) for c in coverage]))
        self.assertEqual(['Foo', 'All_Foo_Tests', 'AllTests', 'All_Bar_Tests',
                            'All_Bar_Nested_Tests', 'Bar'],
                        [c.attr['name'] for c in coverage])
        self.assertEqual(['Foo/classes/Foo.php',
                                'Foo/tests/Foo/AllTests.php',
                                'Foo/tests/AllTests.php',
                                'Foo/tests/Bar/AllTests.php',
                                'Foo/tests/Bar/Nested/AllTests.php',
                                'Foo/classes/Bar.php'],
                        [c.attr['file'] for c in coverage])
        self.assertEqual([100, 0, 0, 0, 0, 100],
                        [c.attr['percentage'] for c in coverage])