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

Joe Holder joe.holder at gmail.com
Tue Apr 9 03:41:56 PDT 2019


HI Danny,

I used these instructions

https://coverage.readthedocs.io/en/v4.5.x/

specifically 'pip install coverage'

(mocking) joe at joe-XPS-15-9570:~/pandora_edge_svncheck$ python -m coverage
--version
Coverage.py, version 4.5.3 with C extension
Documentation at https://coverage.readthedocs.io
(mocking) joe at joe-XPS-15-9570:~/pandora_edge_svncheck$ coverage --version
Coverage.py, version 4.5.3 with C extension
Documentation at https://coverage.readthedocs.io
(mocking) joe at joe-XPS-15-9570:~/pandora_edge_svncheck$

Thanks

Joe



On Tue, 9 Apr 2019 at 11:31, Danny Staple -X (dastaple - TRITON UK BIDCO
LIMITED c/o Alter Domus (UK) Limited -OBO at Cisco) <dastaple at cisco.com>
wrote:

> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20190409/2926aede/attachment.htm>


More information about the testing-in-python mailing list