Exemple #1
0
"""
[ #477608 ] os.path.getmtime() missing
"""

import support
import os

s = os.stat("test331.py")

if s[8] != os.path.getmtime("test331.py"):
    raise support.TestWarning("Modification time was wrong")

if s[7] != os.path.getatime("test331.py"):
    raise support.TestWarning("Access time was wrong")

Exemple #2
0
"""
[ #448398 ] open('test.txt','w').write('test') fails
"""

import support

support.runJython("test322m.py")

import os

l = os.stat("test322.out")[6]

if l != 7:
    raise support.TestWarning('The file should have been auto flushed')
Exemple #3
0
"""
Test that the case of the module extension does not matter.
As the registry documentation says, this will only work if options.caseok is true.
"""

import support

if support.UNIX:
    raise support.TestWarning("this will fail on unix platforms")

from org.python.core import Options
switchedCase = 0
if not Options.caseok:
    switchedCase = 1
    Options.caseok = 1
try:
    import test305m  # the file is named test305m.PY
finally:
    if switchedCase:
        Options.caseok = 0
Exemple #4
0
"""
[ #477793 ] os.utime() is missing
"""

import support

import os
f = open("test330.out", "w")
f.close()

m = os.stat("test330.out")[8]
os.utime("test330.out", (0, 0))
if os.stat("test330.out")[8] != 0:
    raise support.TestWarning("Modification time not changed #1")

os.utime("test330.out", (m, m))
if os.stat("test330.out")[8] != m:
    raise support.TestError("Modification time not changed #2")

Exemple #5
0
"""

"""

import support

support.compileJPythonc("test188c.py", output="test188.err")

if support.grep("jpywork/test188c.java", "extends .*ListCellRenderer",
                count=1) != 1:
    raise support.TestWarning(
        "test188c should extends ListCellRenderer (but properly never will)")
Exemple #6
0
"""
Test class identity for inner classes
[ #452947 ] Class of innerclass inst <> innerclas
"""

import support

support.compileJava('test319j.java')

import test319j

id1 = id(test319j.inner)
id2 = id(test319j.mkinner().__class__)

if id1 != id2:
    print "innerclass different", test319j.inner, test319j.mkinner().__class__
    raise support.TestWarning("innerclass different %s %s" %
                              (test319j.inner, test319j.mkinner().__class__))
Exemple #7
0
"""
Classes with greater a protected constructor can be subclassed and instantiated
Tests bug #649582
"""

import support

support.compileJava("classes/test395j1.java")
support.compileJava("classes/test395j2.java")

import test395j2


class Subclass(test395j2):
    def __init__(self):
        test395j2.__init__(self)


try:
    Subclass()
except AttributeError:
    raise support.TestWarning(
        'Unable to access protected superclass constructor')
Exemple #8
0
test for
[ 730156 ] java.lang.VerifyError with very simple Python source
"""
import support

code = """
def method():
     try:
         for dummy in [1,2,3]:
             try:
                 return "result"
             except:
                 pass
     finally:
         pass
"""

import java.lang

try:
    c = compile(code, "<snippet>", "exec")
except java.lang.VerifyError, e:
    raise support.TestWarning(
        "try-for-try-finally still produces invalid bytecode")

d = {}

exec code in d

if d['method']() != 'result':
    raise support.TestError("wrong result")
Exemple #9
0
"""
Check an array can be created from a string.
"""

import support

from jarray import array
s = "abcdef"
try:
    a = array(s, 'b')
except TypeError, e:
    raise support.TestWarning(
        "I think an ascii string should be auto converted to a byte array")
Exemple #10
0
try:
    from java.util.regex import Pattern
    p = Pattern.compile("xxx")
    m = p.split("ABCDEFG")
except ImportError, e:
    import support
    raise support.TestWarning(
        "JVM version >= 1.4 needed to test PyString -> CharSequence")
Exemple #11
0
"""

"""

import support

raise support.TestWarning(
    "mixing base classes between Jython and Java is not supported")

import java.util
import org.python.core


class LX(org.python.core.PyList, java.util.List):
    pass


l = LX()

try:
    l.add('x')
except AttributeError:
    pass
else:
    raise support.TestError("expected an AttributeError")
Exemple #12
0
"""
[ 531256 ] Constructor problem using newInstance()
"""

import support

support.compileJava("test364p/X.java")
support.compileJava("test364p/Y.java")

from test364p import X, Y


class PyX(X):
    pass


class PyY(Y):
    pass


PyX.useClass(PyY)
X()  # OK
try:
    PyX()  # Not OK prints 'TypeError: Proxy instance reused'
except TypeError:
    raise support.TestWarning('Class ctor should mix with newInstance()')
Exemple #13
0
"""
Test a obviously corrupt $py.class file.
"""

import support
import java

f = open("test298m1.py", "w")
f.close()

f = open("test298m1$py.class", "w")
f.close()

try:
    import test298m1
except ImportError, e:
    pass
except java.lang.ArrayIndexOutOfBoundsException:
    raise support.TestWarning('Should not throw an ArratIndexOutOfBound')
else:
    raise support.TestError('Should throw an import error')

Exemple #14
0
"""
Basic test, just raises a TestWarning
"""

import support

raise support.TestWarning('A test of TestWarning. It is not an error')
Exemple #15
0
   pass

class foo:
   pass

""")
f.close()

support.compileJPythonc("test260s1.py", output="test260.err")



import os
os.remove("test260s1.py")

import sys, types
sys.path[:0] = ['jpywork']

import test260s1

#print dir(test260s1)
#print test260s1.P, type(test260s1.P)
#print test260s1.foo, type(test260s1.foo)

del sys.path[0]

if not hasattr(test260s1, "foo"):
    raise support.TestWarning("the python class should also be visible as a module attribute");


Exemple #16
0
"""
"%#.0f", "%e" and "%+f" w/ negative numbers don't print correctly.
"""

import support

if "%#.0f" % 5 != "5.":
    raise support.TestWarning("Format Error #1 %#.0f" % 5)
if "%.1f" % 5 != "5.0":
    raise support.TestError("Format Error #2 %.1f" % 5)

if "%e" % -1e-6 != "-1.000000e-006":
    raise support.TestError("Format Error #3 %e" % -1e-6)
if "%e" % 0 != "0.000000e+000":
    raise support.TestError("Format Error #4 %e" % 0)
if "%e" % 1e-6 != "1.000000e-006":
    raise support.TestError("Format Error #5 %e" % 1e-6)

if "%+f" % -5 != "-5.000000":
    raise support.TestError("Format Error #6 %+f" % -5)
if "%+f" % 5 != "+5.000000":
    raise support.TestError("Format Error #7 %+f" % 5)

import java

java.util.Locale.setDefault(java.util.Locale("us", ""))

if "%#.0f" % 5 != "5.":
    raise support.TestError("Format Error #8")
if "%.1f" % 5 != "5.0":
    raise support.TestError("Format Error #9")
Exemple #17
0
import support

import java.awt.geom
d = dir(java.awt.geom)
#print d
if "EllipseIterator" not in d:
    raise support.TestWarning("Non-public class should by visible when " +
                              "respectJava is false")