PyCharm, Django: zero code coverage

后端 未结 4 1059
长情又很酷
长情又很酷 2021-02-19 02:56

PyCharm has a \"Run with Coverage\" action for Django test targets. This runs the tests, but shows zero test coverage (0% files, not covered in the project pane, and all red in

4条回答
  •  甜味超标
    2021-02-19 03:47

    I've also been trying to solve this issue in Ubuntu.

    At the moment I tried with both the apt-get Python and the Enthought Canopy stack, with no success. In Windows however it does work (using Canopy).

    I've used the following code:

    # in a.py
    class A(object):
    
        def p(self, a):
            return a
    
    # in test_a.py
    from unittest import TestCase, main
    from a import A
    
    class TestA(TestCase):
        def test_p(self):
            inst = A()
            val = inst.p("a")
            self.assertEqual("a", val)
    
    
    if _name_ == "__main__":
        main()
    

提交回复
热议问题