[TIP] using coverage with unittest and mock with python 3.6.7

Danny Staple -X (dastaple - TRITON UK BIDCO LIMITED c/o Alter Domus (UK) Limited -OBO at Cisco) dastaple at cisco.com
Tue Apr 9 03:31:35 PDT 2019


How have you installed coverage? Are you certain you are running a python3 coverage and not a python2.7 one?
Thanks,
Danny

> On 9 Apr 2019, at 11:25, Joe Holder <joe.holder at gmail.com> wrote:
> 
> Hi,
> 
> I have some test classes that run unittests and have use mock patch object - I can run them ok from the command line - but when I run them via coverage I get 
> 
> import unittest.mock
> ImportError: No module named mock
> 
> I am running the test class file which has a unittest.main in it.
> 
> I am running it from one directory up from the source (the source is in a subdir called 'docker')
> 
> so 
> 'python docker/test_svn_checker_writer.py '
> 
> runs the tests ok
> 
> but
> 'coverage run docker/test_svn_checker_writer.py' - fails with the import error.  This is on ubunto btw.
> 
> Can anyone help?
> 
> Thanks
> 
> Joe
> 
> 
> _______________________________________________
> 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