Python [4]

如何参与开源社区

Posted by ZYT on December 6, 2018

向开源社区贡献

When contributing code, you’ll want to follow this checklist:

  1. Fork the repository on GitHub.
  2. Run the tests to confirm they all pass on your system. If they don’t, you’ll need to investigate why they fail. If you’re unable to diagnose this yourself, raise it as a bug report by following the guidelines in this document: Bug Reports.
  3. Write tests that demonstrate your bug or feature. Ensure that they fail.
  4. Make your change.
  5. Run the entire test suite again, confirming that all tests pass including the ones you just added.
  6. Send a GitHub Pull Request to the main repository’s master branch. GitHub Pull Requests are the expected method of code collaboration on this project.

在其中的第 2 步可以创建虚拟环境,防止环境冲突

$ git clone https://project.git
$ cd project

# virtualenv
$ virtualenv -p python3 venv 
$ source venv/bin/activate
[安装程序](venv) $ pip install --editable .
[安装依赖](venv) $ pip install -r requirements.txt
(venv) $ py.test tests   # Runing test
(venv) $ deactivate  # 退出虚拟环境

# tox
$ tox -e py36

# 执行特定测试
$ tox -e flake8

# 执行特定文件测试
$ tox -e py36 tests/test_file.py