@@ -14,7 +14,7 @@ How is PyPy Tested?
1414
1515In this post I want to give an overview of how the PyPy project does and thinks
1616about testing. PyPy takes testing quite seriously and has done some from the
17- start of the project. In the post I want to present the different styles of
17+ start of the project. Here I want to present the different styles of
1818tests that PyPy has, when we use them and how I think about them.
1919
2020
@@ -116,7 +116,7 @@ just completely regular Python 2 classes that behave in the regular way when
116116run on top of a Python interpreter.
117117
118118In CPython, these tests don't really have an equivalent. They would correspond
119- to tests that are written in C and that can access test the logic of all the C
119+ to tests that are written in C and that can test the logic of all the C
120120functions of CPython that execute certain functionality, accessing the internals
121121of C structs in the process. `¹ `_
122122
@@ -181,27 +181,30 @@ The CPython Test Suite
181181We also use the CPython Test suite as a final check to see whether our
182182interpreter correctly implements all the features of the Python language. In
183183that sense it acts as some kind of compliance test suite that checks whether we
184- implement the language correctly. The test suite is not perfect for this
185- purpose. Since it is written for CPython's purposes during its development, a
184+ implement the language correctly. The test suite is not perfect for this.
185+ Since it is written for CPython's purposes during its development, a
186186lot of the tests check really specific CPython implementation details. Examples
187187for these are tests that check that ``__del__ `` is called immediately after
188188objects go out of scope (which only happens if you use reference counting as a
189- garbage collection strategy, which PyPy doesn't do). Other examples are checking
189+ garbage collection strategy, PyPy uses a `different approach to garbage
190+ collection `_). Other examples are checking
190191for exception error messages very explicitly. However, the CPython test suite
191192has gotten a lot better in these regards over time, by adding
192193``support.gc_collect() `` calls to fix the former problem, and by marking some
193194very specific tests with the ``@impl_detail `` decorator. Thanks to all the
194195CPython developers who have worked on this!
195196
197+ .. _`different approach to garbage collection` : https://www.pypy.org/posts/2013/10/incremental-garbage-collector-in-pypy-8956893523842234676.html
198+
196199In the process of re-implementing CPython's functionality and running CPython's
197200tests suite, PyPy can often also be a good way to find bugs in CPython. While we
198201think about the corner cases of some Python feature we occasionally find
199202situations where CPython didn't get everything completely correct either, which
200203we then report back.
201204
202205
203- Testing Performance
204- =====================
206+ Testing for Performance Regressions
207+ ====================================
205208
206209All the tests we described so far are checking *behaviour *. But one of PyPy's
207210important goals is to be a *fast * implementation not "just" a correct one. Some
@@ -221,7 +224,7 @@ representation`_ that the JIT uses to produce machine code from.
221224.. _`intermediate representation` : https://www.pypy.org/posts/2018/09/the-first-15-years-of-pypy-3412615975376972020.html
222225
223226As an example, here is a small test that loading the attribute of a constant
224- global instance can be completely constant folded away
227+ global instance can be completely constant folded away:
225228
226229.. code :: python
227230
@@ -290,7 +293,7 @@ Footnotes
290293
291294.. _`¹` :
292295
293- CPython has the `_testcapimodule.c ` and related modules, that are used to
296+ ¹ CPython has the `_testcapimodule.c ` and related modules, that are used to
294297unit-test the C-API. However, these are still driven from Python tests using
295298the ``unittest `` framework and wouldn't run without the Python interpreter
296299already working.
@@ -304,8 +307,8 @@ then having a test class with the pattern ``class AppTest*``. We haven't
304307converted all of them to the new style yet, even though the old style is
305308quite weird: since the ``test_*.py `` files are themselves parsed by
306309Python 2, the tests methods in ``AppTest* `` classes need to be written in the
307- subset of Python 3 that is also valid Python 2 syntax, leading to a lot of
308- confusion.
310+ subset of Python 3 syntax that is also valid Python 2 syntax, leading to a lot
311+ of confusion.
309312
310313.. _`³` :
311314
0 commit comments