pytest-freezegun | Easily freeze time in pytest test + fixtures | Plugin library
kandi X-RAY | pytest-freezegun Summary
kandi X-RAY | pytest-freezegun Summary
Easily freeze time in pytest test + fixtures
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of pytest-freezegun
pytest-freezegun Key Features
pytest-freezegun Examples and Code Snippets
Community Discussions
Trending Discussions on pytest-freezegun
QUESTION
I have a python3 application running with flask
and I am using Tavern
and pytest
for test cases. The test cases are executed as expected and it shows results correctly. But I always get 0% code coverage.
This is the command line for running tests:
...ANSWER
Answered 2019-Sep-02 at 16:58By default (that is unless you're using an experimental plugin such as https://github.com/taverntesting/tavern-flask), your application code is running in a different OS process to the process which your tests are running in.
Due to the way that the coverage identifies which lines have been executed, it can only test code in the same process as it is running in. You can read more about how it works here: https://coverage.readthedocs.io/en/v4.5.x/howitworks.html
To achieve what you're after - which I assume is to get the coverage of your web server code, run your flask server with coverage.py, e.g. coverage run --source=app flask run
, then run your tests against the server as you are now (minus turning on coverage). The coverage output will then contain info about which lines have been executed when the tavern tests were running when you kill the server.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pytest-freezegun
You can use pytest-freezegun like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page