[0176eb]: Test / CanNotProve / CanNotProve2.tst Maximize Restore History

Download this file

CanNotProve2.tst    39 lines (24 with data), 1.0 kB

 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
35
36
37
# CanNotProve2.tst
We're going to create a zipped egg file with a compiled CanNotProve example in
it and see if pyke can load its compiled files from the zip file.
First, create the egg (in Test/dist) using Test/setup.py:
>>> import os
>>> os.chdir('..') # up to Test directory
>>> import contextlib
>>> import zipfile
>>> with contextlib.closing(zipfile.PyZipFile('CanNotProve.egg', 'w')) as z:
... z.writepy('CanNotProve')
... z.write('CanNotProve/compiled_krb/facts.fbc')
Now, move up another level (so that 'CanNotProve' is not a subdirectory)
>>> os.chdir('..') # up to root source directory
Add the egg to the python path:
>>> import sys
>>> sys.path.insert(0, 'Test/CanNotProve.egg')
Now try the test!
>>> from CanNotProve import test
>>> test.__loader__ # doctest: +ELLIPSIS
<zipimporter ...>
>>> test.Rule_package = 'CanNotProve'
>>> test.dotests()
And finally, delete the egg file:
>>> os.remove('Test/CanNotProve.egg')