When I run the command coverage report -m after running coverage run main.py any of the lines in the methods that I have test are covered, I using a context.py file and I have the following project structure
my_project
├── service
│ ├── __init__.py
│ └── setThings.py
└── test
├── context.py
├── __init__.py
└── test_setThings.py
this is the content of my context.py
import sys
import os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import service
from service import setThings
This is my service setThings.py
from jinja2 import Environment, FileSystemLoader
def check_if_json_property_is_null(json_property):
if(json_property != ""):
return json_property
else:
return " "
and this is my test file
import unittest
import json
from collections import namedtuple
from .context import setThings
class Test_SetThings(unittest.TestCase):
def test_given_none_property_when_checking_if_none_return_empty(self):
#ASSERT
self.assertEqual(" ", setThings.check_if_json_property_is_null(""))
if __name__ == '__main__':
unittest.main()
So after I run coverage report -m it says that the lines inside my service methods are not covered, I'm using
coverage==4.5.3 in my requirements file,
Also I'm running all the commands from the project root