[TIP] Seeking testing framework for code that cannot be tested by Python unittest

Robert Collins robertc at robertcollins.net
Wed Jun 22 20:32:24 PDT 2016


unittest doesn't care about inheritance much (the loader cares, but
nothing else) - but I don't understand when you say 'must be
written... in class X'.

Can you give some more detail about why that is ? E.g. its a GUI
framework and you want to have your assertion take place in response
to a GUI event?

-Rob

On 23 June 2016 at 15:24, Goldberg, Arthur P <arthur.p.goldberg at mssm.edu> wrote:
> Hello
>
> I’ve extensive experience using Python unittest. However, I’ve some new code
> that I cannot test with unittest because the assertions must be applied in a
> derived class (call it class X) that contains methods executed by an
> application layer scheduler. Thus, tests of this code cannot be written as
> methods named test*() in a class derived from unittest.TestCase.
>
> I attempted to address this problem by using pytest, because it is easy to
> write assert statements in class X. However, pytest doesn’t find the assert
> statements. Rather it reports “collected 0 items”.
>
> Investigating further, I ran pytest —debug. In a cryptic, 700+ line log file
> it reports “message: cannot collect test class 'TestSimulationObject'
> because it has a __init__ constructor”. This doesn’t make sense. Python
> classes almost always use an __init__ constructor. Nevertheless, I tried
> removing the class X’s __init__() constructor and initializing its
> attributes through another method. But pytest —debug still reports the same
> message in the debug log.
>
> My primary interest is to automate the testing of class X. It would be nice
> if that could be done with Python unittest by making direct calls to the
> TestCase API but I suspect that would require more effort than I want to
> devote to solving this problem. Probably the best approach would be to use
> another testing framework that offers similar flexibility to pytest, but
> does indeed test Class X.
>
> Please let me know what you think or recommend.
> Thanks
> Arthur
>
> ---
>
> Arthur Goldberg, PhD
> Associate Professor of Genetics and Genomic Sciences
> Icahn Institute for Genomics & Multiscale Biology
> Icahn School of Medicine at Mount Sinai
> 646 526 5020
> Karr Lab
> Arthur.Goldberg at mssm.edu
> Follow us on Twitter @IcahnInstitute
>
>
>
>
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>



More information about the testing-in-python mailing list