directory in the Batavia code. Each built-in is placed inside its own file.
The tests corresponding to Batavia implementations of built-ins are available inside
tests/builtins. The Batavia test infrastructure includes a system to check the compatibility of
In many cases these tests will not cover everything, so you can add your own. For an example look at
test_bool.py file in
tests/builtins. You will see two classes with test cases,
BuiltinBoolFunctionTests. Both derive from
handles running your code in both interpreters and comparing outputs.
Let’s look at some test code that checks if a the Batavia implementation of
bool can handle a
bool-like class that implements
def test_bool_like(self): self.assertCodeExecution(""" class BoolLike: def __init__(self, val): self.val = val def __bool__(self): return self.val == 1 print(bool(BoolLike(0))) print(bool(BoolLike(1))) """)
assertCodeExecution method will run the code provided to it in both implementations. This
code needs to generate some output so that the output can be compared, hence the need to print the
For a given function, run functionname.__doc__ in the Python 3.4 repl
Copy the docstring into the doc
Run the function in Python 3.4
Take a guess at the implementation structure based on the other functions.
Copy the style of the other implemented functions