Привет! Это мой первый пост на dev, поэтому я попытаюсь сделать это быстро и просто.
Если вы хотите встроить встроенные примеры того, где ваш код не удается, вы можете интегрировать Cirrus CI с аннотациями GitHub . Это супер просто, чтобы сделать.
- Начните с написания модульных тестов. Это супер просто.
- Настройка базового трубопровода CI (
.CIRRUS.YML
File). Вы захотите сделать что-то вроде этого:
tests_task: # define Docker container container: image: python:latest # install project requirements and the annotation result builder install_script: | pip install -r ./some-requirements-file.txt pip install unittest-xml-reporting # normally, you would run unittests with the main command # we need to build XML reports, so use this command script: python3 -m xmlrunner tests # replace tests with the name of the module your unittests are in # (always) upload results - even if the tests fail always: unittest_results_artifacts: # where the outputted XML files are path: ./*.xml # required, even though it sounds wrong format: junit
И это все, что вам нужно сделать! Вы должны получить аннотации.
Хорошего дня!
Оригинал: “https://dev.to/rdil/setting-up-python-unittests-with-github-annotations-3li1”