本文整理汇总了Python中TestEnv.TestEnv.test方法的典型用法代码示例。如果您正苦于以下问题:Python TestEnv.test方法的具体用法?Python TestEnv.test怎么用?Python TestEnv.test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestEnv.TestEnv
的用法示例。
在下文中一共展示了TestEnv.test方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestEnv
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
#!/usr/bin/python
# -*- coding: utf-8 -*-
# vi:encoding=utf-8
from TestEnv import TestEnv
te= TestEnv()
te.checkComplainAndAdjustExpected( 0)
def f( self):
return self
te.test( 1==f( 1))
class A:
pass
A.f= f
a=A()
te.test( a==a.f())
te.test( f==a.f.im_func)
te.test( a==a.f.im_self)
te.test( A==a.f.im_class)
def g():
return 1
示例2: TestEnv
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
te= TestEnv()
te.checkComplainAndAdjustExpected( 0)
class MyException (Exception):
def __init__( self, value):
self.value= value
def __str__( self):
return "value of MyException is "+ self.value
try:
raise MyException( "hi")
te.test( False)
except MyException:
te.test( isinstance( sys.exc_info()[ 1], MyException))
te.test( "hi" == sys.exc_info()[ 1].value)
try:
raise MyException( "hi")
te.test( False)
except MyException, e:
te.test( "hi" == e.value)
te.test( isinstance( e, MyException))
te.test( "value of MyException is hi" == str( e))
te.checkComplainAndAdjustExpected( 5)
print te.result()
示例3: TestEnv
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
#!/usr/bin/python
# -*- coding: utf-8 -*-
# vi:encoding=utf-8
from TestEnv import TestEnv
te= TestEnv()
te.checkComplainAndAdjustExpected( 0)
def f( a, b):
te.test( True)
return ( a, b)
te.test( (1, 2)==f(1, 2))
te.test( (1, 2)==f( b=2, a=1))
te.checkComplainAndAdjustExpected( 4)
te.test( (1, 2)==apply( f, (1, 2)))
te.test( (1, 2)==apply( f, (1, 2), dict()))
te.test( (1, 2)==apply( f, (1, 2), {}))
te.test( (1, 2)==apply( f, (1,), { 'b': 2}))
te.test( (1, 2)==apply( f, [1], { 'b': 2}))
te.test( (1, 2)==apply( f, [], { 'b': 2, 'a': 1}))
te.test( (1, 2)==f( *[1, 2], **{}))
te.test( (1, 2)==f( *[1], **{'b': 2}))
示例4: A
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
te.checkComplainAndAdjustExpected( 0)
class A(object):
def f( self):
te.test( True)
class B( A):
def f( self):
super( B, self).f()
te.test( True)
B().f()
te.test( (object,)==A.__bases__)
te.test( (A,)==B.__bases__)
te.checkComplainAndAdjustExpected( 4)
class C:
def f( self):
te.test( True)
class D( C):
def f( self):
C.f( self)
te.test( True)
D().f()
示例5: TestEnv
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
#!/usr/bin/python
# -*- coding: utf-8 -*-
# vi:encoding=utf-8
import sys
from TestEnv import TestEnv
te = TestEnv()
te.checkComplainAndAdjustExpected(0)
te.test(isinstance(str(), str))
te.test(isinstance("", str))
te.test(isinstance("", str))
te.test(isinstance(int(), int))
te.test(isinstance(1, int))
te.test(isinstance(float(), float))
te.test(isinstance(1.0, float))
te.test(isinstance(long(), long))
te.test(isinstance(1L, long))
te.test(isinstance(complex(), complex))
te.test(isinstance(3 + 7j, complex))
te.test(isinstance(dict(), dict))
te.test(isinstance({}, dict))
te.test(isinstance(list(), list))
te.test(isinstance([], list))
te.test(isinstance(tuple(), tuple))
te.test(isinstance((), tuple))
te.test(not isinstance((1), tuple))
te.test(isinstance((1), int))
示例6: TestEnv
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
#!/usr/bin/python
# -*- coding: utf-8 -*-
# vi:encoding=utf-8
from TestEnv import TestEnv
te= TestEnv()
te.checkComplainAndAdjustExpected( 0)
te.test( True)
te.checkComplainAndAdjustExpected( 1)
print te.result()
示例7: TestEnv
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
#!/usr/bin/python
# -*- coding: utf-8 -*-
# vi:encoding=utf-8
from TestEnv import TestEnv
te= TestEnv()
te.checkComplainAndAdjustExpected( 0)
te.test( 1==(lambda x: x)(1))
te.test( 3==(lambda x, y: x+ y)(1, 2))
te.checkComplainAndAdjustExpected( 2)
print te.result()
示例8: TestEnv
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
#!/usr/bin/python
# -*- coding: utf-8 -*-
# vi:encoding=utf-8
from TestEnv import TestEnv
te= TestEnv()
te.checkComplainAndAdjustExpected( 0)
te.test( [1, 2, 3] == range( 1, 4))
te.test( [0, 2, 4] == range( 0, 5, 2))
te.test( 2 == [1, 2, 3][1])
te.test( 3 == [1, 2, 3][-1])
te.test( [1, 2, 3] == [1, 2, 3][0:3])
te.test( [2, 3] == [1, 2, 3][1:])
te.test( [1] == [1, 2, 3][:1])
te.test( [1, 2] == [1, 2, 3][:-1])
te.test( [1, 2, 3] == [ x for x in [1, 2, 3]])
te.test( [[1, 3], [1, 4], [2, 3], [2, 4]] == [[x,y] for x in [1, 2] for y in [3, 4]])
te.test( [[1, 3], [2, 4]] == [[x,y] for x in [1, 2] for y in [3, 4] if (x+2)==y])
te.checkComplainAndAdjustExpected( 11)
print te.result()
示例9: __init__
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
te.checkComplainAndAdjustExpected( 0)
class A:
def __init__( self):
A_self=self
class B:
def getOuter( self):
return A_self
A_self.B=B
a1=A()
b11=a1.B()
b12=a1.B()
a2=A()
b21=a2.B()
b22=a2.B()
te.test( a1== b11.getOuter())
te.test( a1== b12.getOuter())
te.test( a2== b21.getOuter())
te.test( a2== b22.getOuter())
te.checkComplainAndAdjustExpected( 4)
# see also:
print te.result()
示例10: TestEnv
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
#!/usr/bin/python
# -*- coding: utf-8 -*-
# vi:encoding=utf-8
from TestEnv import TestEnv
te= TestEnv()
te.checkComplainAndAdjustExpected( 0)
te.test( "000a" == "a".zfill( 4))
te.test( "a" == "a".zfill( 0))
te.test( " a" == "a".rjust( 4))
te.test( "a" == "a".rjust( 0))
te.test( "a " == "a".ljust( 4))
te.test( "a" == "a".ljust( 0))
te.checkComplainAndAdjustExpected( 6)
print te.result()
示例11: TestEnv
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
#!/usr/bin/python
# -*- coding: utf-8 -*-
# vi:encoding=utf-8
from TestEnv import TestEnv
te = TestEnv()
te.checkComplainAndAdjustExpected(0)
te.test("- a -" == "- %s -" % "a")
te.test("- 2 -" == "- %d -" % 2)
te.test("- {'a': 'b'} -" == "- %s -" % {"a": "b"})
te.test("- b -" == "- %(a)s -" % {"a": "b"})
try:
"- %(c)s -" % {"a": "b"}
te.test(False)
except KeyError:
te.test(True)
te.checkComplainAndAdjustExpected(5)
print te.result()
示例12: TestEnv
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
if not os.path.isdir( 'work'):
os.mkdir( 'work')
try:
os.remove( 'work/dbm_db')
except:
pass
dbm_db= gdbm.open( 'work/dbm_db', 'c')
te= TestEnv()
te.checkComplainAndAdjustExpected( 0)
try:
dbm_db2= gdbm.open( 'work/dbm_db', 'c')
te.test( False)
except gdbm.error, m:
te.test( isinstance( m, gdbm.error))
te.test( "(11, 'Resource temporarily unavailable')" == str( m))
te.test( True)
te.checkComplainAndAdjustExpected( 3)
print te.result()
dbm_db.close()
# see also:
示例13: TestEnv
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
#!/usr/bin/python
# -*- coding: utf-8 -*-
# vi:encoding=utf-8
from TestEnv import TestEnv
te= TestEnv()
te.checkComplainAndAdjustExpected( 0)
te.test( 0==reduce( None, [], 0))
te.test( 0==reduce( (lambda x, y: x+y), [], 0))
te.test( 1==reduce( None, [ 1]))
try:
te.test( 1==reduce( None, [ 1]), 0)
te.test( False)
except TypeError: # TypeError: 'NoneType' object is not callable
te.test( True)
te.test( 1==reduce( (lambda x, y: x+y), [ 1], 0))
te.test( (1+ 1)==reduce( (lambda x, y: x+y), [ 1], 1))
te.test( 1==reduce( (lambda x, y: x+y), [ 1]))
te.test( (1+ 2)==reduce( (lambda x, y: x+y), [ 1, 2]))
te.test( (1+ 2+ 3)==reduce( (lambda x, y: x+y), [ 1, 2, 3]))
te.checkComplainAndAdjustExpected( 9)
# reducing of different types:
te.test( ( 1+ 2+ 3)==reduce( (lambda x, y: x+ int( y)), [ 1, "2", "3"]))
te.test( ( 1+ 1)==reduce( (lambda x, y: x+ int( y)), [ "1"], 1))
示例14: TestEnv
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
te= TestEnv()
te.checkComplainAndAdjustExpected( 0)
class Z:
pass
class A1( Z):
pass
class A2( Z):
pass
class B( A1, A2):
pass
class C:
pass
te.test( issubclass( B, A1))
te.test( issubclass( B, A2))
te.test( not issubclass( C, A1))
te.test( issubclass( A1, A1))
te.test( not issubclass( A1, A2))
te.test( issubclass( B, Z))
te.checkComplainAndAdjustExpected( 6)
print te.result()
示例15: TestEnv
# 需要导入模块: from TestEnv import TestEnv [as 别名]
# 或者: from TestEnv.TestEnv import test [as 别名]
#!/usr/bin/python
# -*- coding: utf-8 -*-
# vi:encoding=utf-8
from TestEnv import TestEnv
te= TestEnv()
te.checkComplainAndAdjustExpected( 0)
te.test( "ab" == "ab")
te.test( "ab" == "a" + "b")
te.test( "ab" == str( "ab"))
te.test( "101" == str( 101))
te.test( "101.0" == str( 101.))
class C:
def __repr__( self):
return "aadebdf7-9cbb-494b-a4ea-496aa32c5702"
te.test( "aadebdf7-9cbb-494b-a4ea-496aa32c5702" == str( C()))
te.test( "aadebdf7-9cbb-494b-a4ea-496aa32c5702" == repr( C()))
te.test( not( "aadebdf7-9cbb-494b-a4ea-496aa32c5702" == C()))
te.checkComplainAndAdjustExpected( 8)
print te.result()