pytest-cov

Why is module not found only when doing unit testing with pytest? [duplicate]

人走茶凉 提交于 2020-08-10 18:53:26
问题 This question already has answers here : PATH issue with pytest 'ImportError: No module named YadaYadaYada' (19 answers) Closed 4 days ago . I'm having a problem running unit tests. I have a project structure like this: Given this directory who-said-what/ | |_ wave_encoder.py | |_ tests/ |_ test_wave_encoder.py where test_wave_encoder.py looks like this: from wave_encoder import * class TestEncoder(): def test_plot_no_fit1(self): encoder = WaveEncoder() self.assertRaises(ValueError, encoder

How to measure coverage when using multirpocessing via pytest?

大憨熊 提交于 2020-04-16 05:12:47
问题 I run my unit tests via pytest. For coverage I use coverage.py. In one of my unit tests, I run a function via multirpocessing and the coverage does not reflect the functions running via multirpocessing , but the asserts work. That's the problem I am trying to solve. The test looks like so: import time import multiprocessing def test_a_while_loop(): # Start through multiprocessing in order to have a timeout. p = multiprocessing.Process( target=foo name="Foo", ) try: p.start() # my timeout time

How to measure coverage when using multirpocessing via pytest?

前提是你 提交于 2020-04-16 05:09:13
问题 I run my unit tests via pytest. For coverage I use coverage.py. In one of my unit tests, I run a function via multirpocessing and the coverage does not reflect the functions running via multirpocessing , but the asserts work. That's the problem I am trying to solve. The test looks like so: import time import multiprocessing def test_a_while_loop(): # Start through multiprocessing in order to have a timeout. p = multiprocessing.Process( target=foo name="Foo", ) try: p.start() # my timeout time

.coveragerc unable to locate files I want omitted

走远了吗. 提交于 2020-04-11 12:25:28
问题 I am using tox to automatically run my tests using pytest and pytest-cov plugin. However, I'm getting coverage reports for the files I omitted in .coveragerc : (env) alex@smartalex-pc:~/.repos/codelib/github/project$ tox [...] ../../../tests/test_module1.py::test_func PASSED [ 3%] [...] ../../../tests/test_module2.py::test_func PASSED [100%] ----------- coverage: platform linux, python 3.6.7-final-0 ----------- Name Stmts Miss Cover ------------------------------------------------------------

Pytests on web.py application not covering methods code

帅比萌擦擦* 提交于 2020-03-22 09:27:30
问题 First of all, sorry if the linguo is not 100% correct or something does not make 100% of sense, I am quite new into web aplication development and posting on stack overflow in general. I have a web.py application and need to test its functionalities with pytest and generate a code coverage report with pytest-cov . I get the tests to work and assert on the responses, but when I generate the code report, all the lines of code inside the methods are uncovered and therefore get a really low test

Run trace.py with pytest

为君一笑 提交于 2020-03-03 03:03:08
问题 I'm trying to get coverage using trace.py when running pytest . I know that pytest has its own coverage plugin pytest-cov but restrictions (number of times each line is executed is unavailable) do not allow me to use that right now. The same for coverage.py I'm trying this command: python3.4 -m trace -c -m -C . pytest test_script.py test_script.py : class TestScript(): def test_print(self): print ('Hello') The output is: nikhilh$ python3.4 -m trace -c -m -C . pytest test_script.py pytest:

Why are most of my project's Django files missing from the PyTest Coverage report?

霸气de小男生 提交于 2020-01-16 16:47:40
问题 I'm running pytest-cov and pytest-django using tox . I have a very simple tox.ini file with limited omit files. The problem is when I run pytest using tox -e unit , I get a limited Coverage report: ---------- coverage: platform darwin, python 3.7.4-final-0 ----------- Name Stmts Miss Cover Missing ---------------------------------------------------------------------------- components/__init__.py 0 0 100% components/client/__init__.py 0 0 100% components/client/admin.py 27 0 100% components

How can pytest-cov report coverage of python code that is executed as a result of pexpect.spawn?

﹥>﹥吖頭↗ 提交于 2019-12-02 02:16:09
问题 I have a Python project that uses pytest-cov for unit testing and code coverage measurement. The directory structure for my project is: rift-python +- rift # The package under test | +- __init__.py | +- __main__.py | +- cli_listen_handler.py | +- cli_session_handler.py | +- table.py | +- ...lots more... +- tests # The tests | +- test_table.py | +- test_sys_2n_l0_l1.py | +- ...more... +- README.md +- .travis.yml +- ... I use Travis to run pytest --cov=rift tests for every checkin, and I use

How can pytest-cov report coverage of python code that is executed as a result of pexpect.spawn?

流过昼夜 提交于 2019-12-01 22:25:45
I have a Python project that uses pytest-cov for unit testing and code coverage measurement. The directory structure for my project is: rift-python +- rift # The package under test | +- __init__.py | +- __main__.py | +- cli_listen_handler.py | +- cli_session_handler.py | +- table.py | +- ...lots more... +- tests # The tests | +- test_table.py | +- test_sys_2n_l0_l1.py | +- ...more... +- README.md +- .travis.yml +- ... I use Travis to run pytest --cov=rift tests for every checkin, and I use codecov to view the code coverage results. The package under test offer a command line interface (CLI)