/usr/lib/python3/dist-packages/astroML/tests/test_pickle_results.py is in python3-astroml 0.3-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import os
from astroML.decorators import pickle_results
def test_pickle_results():
filename = 'tmp.pkl'
@pickle_results('tmp.pkl')
def foo(x):
foo.called = True
return x * x
# cleanup if necessary
if os.path.exists(filename):
os.remove(filename)
# initial calculation: function should be executed
foo.called = False
assert foo(4) == 16
assert foo.called is True
# recalculation: function should not be executed
foo.called = False
assert foo(4) == 16
assert foo.called is False
# recalculation with different input: function should be executed
foo.called = False
assert foo(5) == 25
assert foo.called is True
# cleanup
assert os.path.exists(filename)
os.remove(filename)
|