[TIP] Does testscenarios employ unittest?

Ben Finney ben+python at benfinney.id.au
Sun Sep 25 20:14:55 PDT 2016

boB Stepp <robertvstepp at gmail.com> writes:

> On Sun, Sep 25, 2016 at 9:49 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
> > What you may be doing is inheriting your test case classes from some
> > other class which *itself* is a subclass of ‘unittest.TestCase’.
> The following is what I am using and it appears to work:
> =========================================================
> from testscenarios import TestWithScenarios
> […]
> class TestRightJustify(TestWithScenarios):
>     '''Tests for the function, "right_justify(a_string)", in the "right_justify
>     module".'''

So, how would you test for what I'm proposing above?

What Python tool can you use to test whether ‘TestRightJustify’ is a
subclass of ‘unittest.TestCase’?

Maybe this helps:

    >>> import unittest
    >>> import test_foo
    >>> issubclass(test_foo.TestRightJustify, unittest.TestCase)

> As you can see, I did not have to explicitly import unittests, so thus
> my questions. So what is actually happening here?

This is why it's a good idea to interrogate your code and make it talk,
to tell you where it came from and who it is :-)

 \           “I know that we can never get rid of religion …. But that |
  `\   doesn’t mean I shouldn’t hate the lie of faith consistently and |
_o__)                     without apology.” —Paul Z. Myers, 2011-12-28 |
Ben Finney

More information about the testing-in-python mailing list