@@ -126,7 +126,7 @@ with the exception of ``self`` and ``cls`` as seen in the following example.
126126 self .reset()
127127
128128
129- Running the tests
129+ Running The Tests
130130~~~~~~~~~~~~~~~~~
131131
132132A great way to explore the code base is to run the tests.
@@ -136,7 +136,7 @@ First, install the test dependencies:
136136
137137.. code :: sh
138138
139- $ pip install -e " .[test ]"
139+ $ pip install -e " .[tester ]"
140140
141141 You can run all tests with:
142142
@@ -173,6 +173,73 @@ suite as part of the CI check. This test suite will run in the CI anytime a
173173pull request is opened or updated.
174174
175175
176+ Writing Tests
177+ ~~~~~~~~~~~~~
178+
179+ We strongly encourage contributors to write good tests for their code as
180+ part of the code review process. This helps ensure that your code is doing
181+ what it should be doing.
182+
183+ We strongly encourage you to use our existing tests for both guidance and
184+ homogeneity / consistency across our tests. We use ``pytest `` for our tests.
185+ For more specific pytest guidance, please refer to the `pytest documentation `_.
186+
187+ Within the ``pytest `` scope, :file: `conftest.py ` files are used for common code
188+ shared between modules that exist within the same directory as that particular
189+ :file: `conftest.py ` file.
190+
191+ Unit Testing
192+ ^^^^^^^^^^^^
193+
194+ Unit tests are meant to test the logic of smaller chunks (or units) of the
195+ codebase without having to be wired up to a client. Most of the time this
196+ means testing selected methods on their own. They are meant to test the logic
197+ of your code and make sure that you get expected outputs out of selected inputs.
198+
199+ Our unit tests live under appropriately named child directories within the
200+ ``/tests `` directory. The core of the unit tests live under ``/tests/core ``.
201+ Do your best to follow the existing structure when choosing where to add
202+ your unit test.
203+
204+ Integration Testing
205+ ^^^^^^^^^^^^^^^^^^^
206+
207+ Our integration test suite setup lives under the ``/tests/integration `` directory.
208+ The integration test suite is dependent on what we call "fixtures" (not to be
209+ confused with pytest fixtures). These zip file fixtures, which also live in the
210+ ``/tests/integration `` directory, are configured to run the specific client we are
211+ testing against along with a genesis configuration that gives our tests some
212+ pre-determined useful objects (like unlocked, pre-loaded accounts) to be able to
213+ interact with the client and run our tests.
214+
215+ Though the setup lives in ``/tests/integration ``, our integration module tests are
216+ written across different files within ``/web3/_utils/module_testing ``. The tests
217+ are written there but run configurations exist across the different files within
218+ ``/tests/integration/ ``. The parent ``/integration `` directory houses some common
219+ configuration shared across all client tests, whereas the ``/go_ethereum `` and
220+ ``/parity `` directories house common code to be shared among each respective client
221+ tests.
222+
223+ * :file: `common.py ` files within the client directories contain code that is shared across
224+ all provider tests (http, ipc, and ws). This is mostly used to override tests that span
225+ across all providers.
226+ * :file: `conftest.py ` files within each of these directories contain mostly code that can
227+ be *used * by all test files that exist within the same directory as the :file: `conftest.py `
228+ file. This is mostly used to house pytest fixtures to be shared among our tests. Refer to
229+ the `pytest documentation on fixtures `_ for more information.
230+ * :file: `test_{ client } _{ provider } .py ` (e.g. :file: `test_goethereum_http.py `) files are where
231+ client-and-provider-specific test configurations exist. This is mostly used to override tests
232+ specific to the provider type for the respective client.
233+
234+ Sometimes the client may be bogged down with pending transactions or anything else that may
235+ interfere with your particular test. In this case, it may be useful to run your test at the
236+ front of the test suite. If you feel it makes sense to run a particular test at a specific
237+ position in the test suite, there is a handy ``pytest `` hook that allows us to somewhat
238+ customize the order of our integration tests. This ``pytest_collection_modifyitems `` hook
239+ can be defined within the appropriate ``conftest.py `` file, depending on the scope of the
240+ test suite you want it to affect.
241+
242+
176243Manual Testing
177244~~~~~~~~~~~~~~
178245
@@ -217,7 +284,7 @@ If possible, the change to the release notes file should be included in the
217284commit that introduces the feature or bugfix.
218285
219286
220- Generating new fixtures
287+ Generating New Fixtures
221288~~~~~~~~~~~~~~~~~~~~~~~
222289
223290Our integration tests make use of Geth and Parity/OpenEthereum private networks.
@@ -228,7 +295,7 @@ Before generating new fixtures, make sure you have the test dependencies install
228295
229296.. code :: sh
230297
231- $ pip install -e " .[test ]"
298+ $ pip install -e " .[tester ]"
232299
233300 .. note ::
234301
@@ -237,7 +304,7 @@ Before generating new fixtures, make sure you have the test dependencies install
237304 testing Web3.py functionality against.
238305
239306
240- Geth fixtures
307+ Geth Fixtures
241308^^^^^^^^^^^^^
242309
2433101. Install the desired Geth version on your machine locally. We recommend `py-geth `_ for
@@ -265,7 +332,7 @@ Geth fixtures
265332 you may again include the ``GETH_BINARY `` environment variable.
266333
267334
268- CI testing with a nightly Geth build
335+ CI Testing With a Nightly Geth Build
269336^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
270337
271338Occasionally you'll want to have CI run the test suite against an unreleased version of Geth,
@@ -291,7 +358,7 @@ an unstable client.
2913586. Create a PR and let CI do its thing.
292359
293360
294- Parity/OpenEthereum fixtures
361+ Parity/OpenEthereum Fixtures
295362^^^^^^^^^^^^^^^^^^^^^^^^^^^^
296363
2973641. The most reliable way to get a specific Parity/OE binary is to download
@@ -323,7 +390,7 @@ Parity/OpenEthereum fixtures
323390Releasing
324391~~~~~~~~~
325392
326- Final test before each release
393+ Final Test Before Each Release
327394^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
328395
329396Before releasing a new version, build and test the package that will be released.
@@ -349,7 +416,7 @@ virtualenv for smoke testing:
349416 >>> ...
350417
351418
352- Verify the latest documentation
419+ Verify The Latest Documentation
353420^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
354421
355422To preview the documentation that will get published:
@@ -359,15 +426,15 @@ To preview the documentation that will get published:
359426 $ make docs
360427
361428
362- Preview the release notes
429+ Preview The Release Notes
363430^^^^^^^^^^^^^^^^^^^^^^^^^
364431
365432.. code :: sh
366433
367434 $ towncrier --draft
368435
369436
370- Compile the release notes
437+ Compile The Release Notes
371438^^^^^^^^^^^^^^^^^^^^^^^^^
372439
373440After confirming that the release package looks okay, compile the release notes:
@@ -381,7 +448,7 @@ You may need to fix up any broken release note fragments before committing. Keep
381448running ``make build-docs `` until it passes, then commit and carry on.
382449
383450
384- Push the release to GitHub & PyPI
451+ Push The Release to GitHub & PyPI
385452^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
386453
387454After committing the compiled release notes and pushing them to the master
@@ -392,7 +459,7 @@ branch, release a new version:
392459 $ make release bump=$$ VERSION_PART_TO_BUMP$$
393460
394461
395- Which version part to bump
462+ Which Version Part to Bump
396463^^^^^^^^^^^^^^^^^^^^^^^^^^
397464
398465The version format for this repo is ``{major}.{minor}.{patch} `` for
@@ -418,3 +485,5 @@ version explicitly, like ``make release bump="--new-version 4.0.0-alpha.1 devnum
418485.. _py-geth : https://github.com/ethereum/py-geth
419486.. _Github releases : https://github.com/openethereum/openethereum/releases
420487.. _Build the binary : https://github.com/openethereum/openethereum/#3-building-
488+ .. _pytest documentation : https://docs.pytest.org/en/latest
489+ .. _pytest documentation on fixtures : https://docs.pytest.org/en/latest/how-to/fixtures.html
0 commit comments