Testing and coverage of python code

Hello, may I ask about an simple example how to set the circle.yml to run on two version of python eg 2.7 and 3.4 and perform the testing (actually I am getting “Set Up Test Summary” message) and in the end do some code coverage summary as internal way or send the the report to another tool with a token. Thanks

You might want to look into using tox. which makes it possible to test as many versions as you like and this makes it CI independent. Circle also comes with native tox support (auto-detects tox.ini and runs tests).

1 Like

How can I test both Python 2.7 and 3.6 without adding a tox.ini file? Introducing tox.ini into this repo that I do not own will effect other CI processes.

1 Like
version: 2.0

jobs:
  Python_2.7:
      docker:
        - image: circleci/python:2.7
      steps: &steps
        - checkout
        - run: sudo pip install -r requirements.txt
        - run: sudo pip install coverage flake8 pytest
        - run: python --version ; pip --version ; pwd ; ls
        # stop the build if there are Python syntax errors or undefined names
        - run: flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
        # exit-zero treats all errors as warnings.  The GitHub editor is 127 chars wide      
        - run: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
        - run: pytest
  Python_3.6:
      docker:
        - image: circleci/python:3.6
      steps: *steps

workflows:
  version: 2
  build:
    jobs:
      - Python_2.7
      - Python_3.6
2 Likes

then setting the test results…

    - run: mkdir test-reports
    - run: coverage report && coverage xml -o test-reports/coverage.xml
    - store_test_results:
       path: test-reports
    - store_artifacts:
       path: test-reports
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.