summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarrod Millman <jarrod.millman@gmail.com>2021-05-26 15:14:34 -0700
committerGitHub <noreply@github.com>2021-05-26 15:14:34 -0700
commit505d4f42521cb37907336c73750cf85a5ad42edc (patch)
tree2d0558e6e792ad5a6467318ec1548ef8f3d1aef5
parent90f877368227a66908311a381df146cf103a4001 (diff)
downloadnetworkx-505d4f42521cb37907336c73750cf85a5ad42edc.tar.gz
Add info about testing and examples (#4582)
* Add info about testing and examples * Update CONTRIBUTING.rst Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Document testing * Incorporate feedback * Cleanup * rst nit. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
-rw-r--r--CONTRIBUTING.rst32
-rw-r--r--networkx/conftest.py13
2 files changed, 45 insertions, 0 deletions
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 9c699f56..d15747e1 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -353,6 +353,38 @@ detailing the test coverage::
networkx/algorithms/approximation/clique.py 42 1 18 1 97%
...
+Adding tests
+------------
+
+If you're **new to testing**, see existing test files for examples of things to do.
+**Don't let the tests keep you from submitting your contribution!**
+If you're not sure how to do this or are having trouble, submit your pull request
+anyway.
+We will help you create the tests and sort out any kind of problem during code review.
+
+Adding examples
+---------------
+
+The gallery examples are managed by
+`sphinx-gallery <https://sphinx-gallery.readthedocs.io/>`_.
+The source files for the example gallery are ``.py`` scripts in ``examples/`` that
+generate one or more figures. They are executed automatically by sphinx-gallery when the
+documentation is built. The output is gathered and assembled into the gallery.
+
+You can **add a new** plot by placing a new ``.py`` file in one of the directories inside the
+``examples`` directory of the repository. See the other examples to get an idea for the
+format.
+
+.. note:: Gallery examples should start with ``plot_``, e.g. ``plot_new_example.py``
+
+General guidelines for making a good gallery plot:
+
+* Examples should highlight a single feature/command.
+* Try to make the example as simple as possible.
+* Data needed by examples should be included in the same directory and the example script.
+* Add comments to explain things are aren't obvious from reading the code.
+* Describe the feature that you're showcasing and link to other relevant parts of the
+ documentation.
Bugs
----
diff --git a/networkx/conftest.py b/networkx/conftest.py
index ad541ba0..434ff746 100644
--- a/networkx/conftest.py
+++ b/networkx/conftest.py
@@ -1,3 +1,16 @@
+"""
+Testing
+=======
+
+General guidelines for writing good tests:
+
+- doctests always assume ``import networkx as nx`` so don't add that
+- prefer pytest fixtures over classes with setup methods.
+- use the ``@pytest.mark.parametrize`` decorator
+- use ``pytest.importskip`` for numpy, scipy, pandas, and matplotlib b/c of PyPy.
+ and add the module to the relevant entries below.
+
+"""
import pytest
import networkx
import sys