Skip to content

Unit test generators are unsupported #735

@njsaunders

Description

@njsaunders

Due to "limited support" in xmlrunner for unittest.TestCase.subTest and the fact that pybuilder uses xmlrunner to run unit tests, unit test generators are unsupported in pybuilder, which is a shame because they're a really nice feature :)

Expected Behavior

Tests run - 3 pass, 3 fail.

Actual Behavior

BUILD FAILED - TypeError: issubclass() arg 2 must be a class or tuple of classes (xmlrunner/result.py:375)

PyBuilder version 0.12.6
Build started at 2020-07-17 12:58:14
------------------------------------------------------------
[INFO]  Building testcase_pyb version 1.0.dev0
[INFO]  Executing build in /Users/neil/testcase_pyb
[INFO]  Going to execute task publish
[INFO]  Processing plugin packages 'coverage~=5.0' to be installed with {'upgrade': True}
[INFO]  Processing plugin packages 'flake8~=3.7' to be installed with {'upgrade': True}
[INFO]  Processing plugin packages 'pypandoc~=1.4' to be installed with {'upgrade': True}
[INFO]  Processing plugin packages 'setuptools>=38.6.0' to be installed with {'upgrade': True}
[INFO]  Processing plugin packages 'twine>=1.15.0' to be installed with {'upgrade': True}
[INFO]  Processing plugin packages 'unittest-xml-reporting~=2.5.2' to be installed with {'upgrade': True}
[INFO]  Processing plugin packages 'wheel>=0.34.0' to be installed with {'upgrade': True}
[INFO]  Creating target 'build' VEnv in '/Users/neil/testcase_pyb/target/venv/build/cpython-3.7.7.final.0'
[INFO]  Creating target 'test' VEnv in '/Users/neil/testcase_pyb/target/venv/test/cpython-3.7.7.final.0'
[INFO]  Requested coverage for tasks: pybuilder.plugins.python.unittest_plugin:run_unit_tests
[INFO]  Running unit tests
[INFO]  Executing unit tests from Python modules in /Users/neil/testcase_pyb/src/unittest/python
------------------------------------------------------------
BUILD FAILED - TypeError: issubclass() arg 2 must be a class or tuple of classes (xmlrunner/result.py:375)
------------------------------------------------------------
Build finished at 2020-07-17 12:58:59
Build took 44 seconds (44762 ms)```

Steps to Reproduce the Problem

  1. Initialise a new pybuilder project
  2. Write the following to ./src/unittest/python/generator_tests.py (The example code taken from here)
import unittest

class NumbersTest(unittest.TestCase):

    def test_even(self):
        """
        Test that numbers between 0 and 5 are all even.
        """
        for i in range(0, 6):
            with self.subTest(i=i):
                self.assertEqual(i % 2, 0)
  1. Run the tests with pyb -v

Specifications

  • Version: pyb 0.12.6, Python 3.7.7
  • Platform: MacOS Catalina (10.15.5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions