PageRenderTime 44ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/doc/contributing.rst

https://gitlab.com/0072016/coveragepy
ReStructuredText | 172 lines | 122 code | 50 blank | 0 comment | 0 complexity | 66d923b2c79355e54c301d37b9d8113d MD5 | raw file
  1. .. Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
  2. .. For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt
  3. .. _contributing:
  4. ===========================
  5. Contributing to coverage.py
  6. ===========================
  7. .. :history: 20121112T154100, brand new docs.
  8. .. highlight:: console
  9. I welcome contributions to coverage.py. Over the years, dozens of people have
  10. provided patches of various sizes to add features or fix bugs. This page
  11. should have all the information you need to make a contribution.
  12. One source of history or ideas are the `bug reports`_ against coverage.py.
  13. There you can find ideas for requested features, or the remains of rejected
  14. ideas.
  15. .. _bug reports: https://bitbucket.org/ned/coveragepy/issues?status=new&status=open
  16. Before you begin
  17. ----------------
  18. If you have an idea for coverage.py, run it by me before you begin writing
  19. code. This way, I can get you going in the right direction, or point you to
  20. previous work in the area. Things are not always as straightforward as they
  21. seem, and having the benefit of lessons learned by those before you can save
  22. you frustration.
  23. Getting the code
  24. ----------------
  25. The coverage.py code is hosted on a `Mercurial`_ repository at
  26. https://bitbucket.org/ned/coveragepy. To get a working environment, follow
  27. these steps:
  28. #. (Optional, but recommended) Create a virtualenv to work in, and activate
  29. it.
  30. #. Clone the repo::
  31. $ hg clone https://bitbucket.org/ned/coveragepy
  32. $ cd coveragepy
  33. #. Install the requirements::
  34. $ pip install -r requirements/dev.pip
  35. #. Install a number of versions of Python. Coverage.py supports a wide range
  36. of Python versions. The more you can test with, the more easily your code
  37. can be used as-is. If you only have one version, that's OK too, but may
  38. mean more work integrating your contribution.
  39. Running the tests
  40. -----------------
  41. The tests are written as standard unittest-style tests, and are run with
  42. `tox`_::
  43. $ tox
  44. py27 create: /Users/ned/coverage/trunk/.tox/py27
  45. py27 installdeps: nose==1.3.7, mock==1.3.0, PyContracts==1.7.6, gevent==1.0.2, eventlet==0.17.4, greenlet==0.4.7
  46. py27 develop-inst: /Users/ned/coverage/trunk
  47. py27 installed: -f /Users/ned/Downloads/local_pypi,-e hg+ssh://hg@bitbucket.org/ned/coveragepy@22fe9a2b7796f6498aa013c860c268ac21651226#egg=coverage-dev,decorator==4.0.2,eventlet==0.17.4,funcsigs==0.4,gevent==1.0.2,greenlet==0.4.7,mock==1.3.0,nose==1.3.7,pbr==1.6.0,PyContracts==1.7.6,pyparsing==2.0.3,six==1.9.0,wheel==0.24.0
  48. py27 runtests: PYTHONHASHSEED='1294330776'
  49. py27 runtests: commands[0] | python setup.py --quiet clean develop
  50. py27 runtests: commands[1] | python igor.py zip_mods install_egg remove_extension
  51. py27 runtests: commands[2] | python igor.py test_with_tracer py
  52. === CPython 2.7.10 with Python tracer (.tox/py27/bin/python) ===
  53. ............................................................................(etc)
  54. ----------------------------------------------------------------------
  55. Ran 592 tests in 65.524s
  56. OK (SKIP=20)
  57. py27 runtests: commands[3] | python setup.py --quiet build_ext --inplace
  58. py27 runtests: commands[4] | python igor.py test_with_tracer c
  59. === CPython 2.7.10 with C tracer (.tox/py27/bin/python) ===
  60. ............................................................................(etc)
  61. ----------------------------------------------------------------------
  62. Ran 592 tests in 69.635s
  63. OK (SKIP=4)
  64. py33 create: /Users/ned/coverage/trunk/.tox/py33
  65. py33 installdeps: nose==1.3.7, mock==1.3.0, PyContracts==1.7.6, greenlet==0.4.7
  66. py33 develop-inst: /Users/ned/coverage/trunk
  67. py33 installed: -f /Users/ned/Downloads/local_pypi,-e hg+ssh://hg@bitbucket.org/ned/coveragepy@22fe9a2b7796f6498aa013c860c268ac21651226#egg=coverage-dev,decorator==4.0.2,greenlet==0.4.7,mock==1.3.0,nose==1.3.7,pbr==1.6.0,PyContracts==1.7.6,pyparsing==2.0.3,six==1.9.0,wheel==0.24.0
  68. py33 runtests: PYTHONHASHSEED='1294330776'
  69. py33 runtests: commands[0] | python setup.py --quiet clean develop
  70. py33 runtests: commands[1] | python igor.py zip_mods install_egg remove_extension
  71. py33 runtests: commands[2] | python igor.py test_with_tracer py
  72. === CPython 3.3.6 with Python tracer (.tox/py33/bin/python) ===
  73. ............................................S...............................(etc)
  74. ----------------------------------------------------------------------
  75. Ran 592 tests in 73.007s
  76. OK (SKIP=22)
  77. py33 runtests: commands[3] | python setup.py --quiet build_ext --inplace
  78. py33 runtests: commands[4] | python igor.py test_with_tracer c
  79. === CPython 3.3.6 with C tracer (.tox/py33/bin/python) ===
  80. ............................................S...............................(etc)
  81. ----------------------------------------------------------------------
  82. Ran 592 tests in 72.071s
  83. OK (SKIP=5)
  84. (and so on...)
  85. Tox runs the complete test suite twice for each version of Python you have
  86. installed. The first run uses the Python implementation of the trace function,
  87. the second uses the C implementation.
  88. To limit tox to just a few versions of Python, use the ``-e`` switch::
  89. $ tox -e py27,py33
  90. To run just a few tests, you can use nose test selector syntax::
  91. $ tox tests.test_misc:SetupPyTest.test_metadata
  92. This looks in `tests/test_misc.py` to find the `SetupPyTest` class, and runs
  93. the `test_metadata` test method.
  94. Of course, run all the tests on every version of Python you have, before
  95. submitting a change.
  96. Lint, etc
  97. ---------
  98. I try to keep the coverage.py as clean as possible. I use pylint to alert me
  99. to possible problems::
  100. $ make lint
  101. pylint coverage setup.py tests
  102. python -m tabnanny coverage setup.py tests
  103. python igor.py check_eol
  104. The source is pylint-clean, even if it's because there are pragmas quieting
  105. some warnings. Please try to keep it that way, but don't let pylint warnings
  106. keep you from sending patches. I can clean them up.
  107. Lines should be kept to a 100-character maximum length.
  108. Coverage testing coverage.py
  109. ----------------------------
  110. Coverage.py can measure itself, but it's complicated. The process has been
  111. packaged up to make it easier::
  112. $ make metacov metahtml
  113. Then look at htmlcov/index.html. Note that due to the recursive nature of
  114. coverage.py measuring itself, there are some parts of the code that will never
  115. appear as covered, even though they are executed.
  116. Contributing
  117. ------------
  118. When you are ready to contribute a change, any way you can get it to me is
  119. probably fine. A pull request on Bitbucket is great, but a simple diff or
  120. patch is great too.
  121. .. _Mercurial: http://mercurial.selenic.com/
  122. .. _tox: http://tox.testrun.org/