在CircleCI的标准库上运行Python覆盖率?

2024-06-16 10:24:09 发布

您现在位置:Python中文网/ 问答频道 /正文

在CircleCI上运行coverage时,coverage报告为我的所有模块和Python标准库生成coverage。据我所知,这不是我想要的行为。你知道为什么Python标准库会包含在报道中吗

我试着看了一下--omit,这看起来不太有希望,文档清楚地指出覆盖范围不应该包括Python标准库

My.circleci config.yml的-run如下所示:

      - run:
          name: Run tests
          command: |
            docker run -it \
                       --name tests \
                       --link circle_db:db \
                       --env-file test.env \
                       -a STDOUT \
                       -u 0 \
                       COMPANY-dev \
                       sh -c "mkdir -p /tests/django && coverage run manage.py test --with-xunit --xunit-file=/tests/django/nosetests.xml --exclude test_git_pull && coverage report && coverage html"

我所有的覆盖范围命令都在这一行中:

coverage run manage.py test --with-xunit --xunit-file=/tests/django/nosetests.xml --exclude test_git_pull && coverage report && coverage html

我希望这只涵盖我自己的模块,跳过python库我的覆盖率报告的前几行如下:

/python/lib/python3.7/site-packages/dateutil/_version.py                                                                      1      0   100%
/python/lib/python3.7/site-packages/dateutil/easter.py                                                                       27     20    26%
/python/lib/python3.7/site-packages/dateutil/parser/__init__.py                                                              32      4    88%
/python/lib/python3.7/site-packages/dateutil/parser/_parser.py                                                              795    680    14%

我自己的模块也包括在内,但我不想包括Python标准库。谢谢大家


Tags: 模块djangorunpytestparser标准lib