[TIP] Mocking in every test.

Bruno Oliveira nicoddemus at gmail.com
Wed Aug 17 05:17:59 PDT 2016


Hi,

On Wed, Aug 17, 2016 at 8:56 AM Iñaki Malerba <inakimmalerba at gmail.com>
wrote:

> Is it any way to mock it on the test's class and not in every test that
> involves that tested class?
>


You can use any patcher as a class decorator and it will be applied to all
tests in that class[1]:

@mock.patch('module.Class.method', return_value=True)
class T(unittest.TestCase):
    def test_foo(self):
        ...

Cheers,

[1] http://www.voidspace.org.uk/python/mock/patch.html#test-prefix


>
> Thanks in advance.
> __
> Martin Iñaki Malerba
> inakimmalerba at gmail.com | +54 02945 15468443
>
> Estudiante de Ing. en Electrónica UTN FRC
> Vicepresidente Subcomisión Cómputos AVEIT
> Miembro Centro de Inv. en Informática para la Ingeniería CIII
> Tesorero Rama Estudiantil UTN FRC IEEE
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20160817/62bd1587/attachment.htm>


More information about the testing-in-python mailing list