@@ -124,17 +124,8 @@ There is also a second class of tests for the interpreter. Those are tests that
124
124
don't run on the level of the implementation. Instead, they are executed *by *
125
125
the PyPy Python interpreter, thus running on the level of the applications run
126
126
by PyPy. Since the interpreter is running Python 3, the tests are also written
127
- in Python 3. They are stored in files with the pattern ``apptest_*.py `` _[#] and
128
- look like "regular" Python 3 tests.
129
-
130
- .. [# ] There is also a deprecated different way to write these tests, by putting
131
- them in the ``test_*.py `` files that interpreter level tests are using and
132
- then having a test class with the pattern ``class AppTest* ``. We haven't
133
- converted all of them to the new style yet, even though the old style is
134
- quite weird: since the ``test_*.py `` files are themselves parsed by
135
- Python 2, the tests methods in ``AppTest* `` classes need to be written in the
136
- subset of Python 3 that is also valid Python 2 syntax, leading to a lot of
137
- confusion.
127
+ in Python 3. They are stored in files with the pattern ``apptest_*.py `` and
128
+ look like "regular" Python 3 tests. `¹ `_
138
129
139
130
Here's an example of how you could write a test equivalent to the one above:
140
131
@@ -163,13 +154,7 @@ fast, given that they run on a stack of two different interpreters.
163
154
164
155
Application-level tests correspond quite closely to CPython's tests suite (which
165
156
is using the unittest framework). Of course in CPython it is not possible to run
166
- the test suite without building the CPython binary using a C compiler. _[#]
167
-
168
- .. [# ] Nit-picky side-note: `C interpreters `_ `are a thing `_! But not that
169
- widely used in practice, or only in very specific situations.
170
-
171
- .. _`C interpreters` : https://root.cern.ch/root/html534/guides/users-guide/CINT.html
172
- .. _`are a thing` : https://www.youtube.com/watch?v=yyDD_KRdQQU
157
+ the test suite without building the CPython binary using a C compiler. `² `_
173
158
174
159
So when do we write application-level tests, and when interpreter-level tests?
175
160
Interpreter-level tests are necessary to test internal data structures that
@@ -294,3 +279,27 @@ to develop the PyPy Python interpreter.
294
279
There is a whole other set of tests for the development of the RPython language,
295
280
the garbage collectors it provides as well as the code that does the automatic
296
281
JIT insertion, maybe I'll cover these in a future post.
282
+
283
+
284
+ Footnotes
285
+ -----------
286
+
287
+ .. _`¹` :
288
+
289
+ ¹ There is also a deprecated different way to write these tests, by putting
290
+ them in the ``test_*.py `` files that interpreter level tests are using and
291
+ then having a test class with the pattern ``class AppTest* ``. We haven't
292
+ converted all of them to the new style yet, even though the old style is
293
+ quite weird: since the ``test_*.py `` files are themselves parsed by
294
+ Python 2, the tests methods in ``AppTest* `` classes need to be written in the
295
+ subset of Python 3 that is also valid Python 2 syntax, leading to a lot of
296
+ confusion.
297
+
298
+ .. _`²` :
299
+
300
+ ² Nit-picky side-note: `C interpreters `_ `are a thing `_! But not that
301
+ widely used in practice, or only in very specific situations.
302
+
303
+ .. _`C interpreters` : https://root.cern.ch/root/html534/guides/users-guide/CINT.html
304
+ .. _`are a thing` : https://www.youtube.com/watch?v=yyDD_KRdQQU
305
+
0 commit comments