File: test323.py

package info (click to toggle)
jython 2.5.3-3%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 43,404 kB
  • ctags: 105,521
  • sloc: python: 351,322; java: 216,346; xml: 1,547; sh: 330; perl: 124; ansic: 102; makefile: 101
file content (29 lines) | stat: -rw-r--r-- 725 bytes parent folder | download | duplicates (9)
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
"""
Tests using a path inside a zip file for zip imports
"""

import support
import zipfile, time

def addZipEntry(zip, name, data):
    entry = zipfile.ZipInfo()
    entry.filename = name
    entry.date_time = time.gmtime(time.time())
    zip.writestr(entry, data)


zip = zipfile.ZipFile("test323.zip", "w", zipfile.ZIP_DEFLATED)

addZipEntry(zip, "Lib/test323m.py", """
assert __name__ == 'test323m', " __name__ should've been test323m but was %s" % __name__
from java.io import File
expected = "test323.zip%sLib/test323m.py" % (File.separator)
assert expected in __file__, "%s should've been in __file__ but was %s" % (expected, __file__)
""")

zip.close()

import sys
sys.path.append("test323.zip/Lib")

import test323m