Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(517)  |  Call(517)  |  Derive(0)  |  Import(0)

src/p/y/pyjs-HEAD/examples/libtest/BuiltinTest.py   pyjs(Download)
        self.assertEqual(max([1,2,3,4]), 4)
        self.assertEqual(min([1,2,3,4]), 1)
        self.assertTrue(max([5,3,4],[6,1,2]) == [6,1,2] , "max([5,3,4],[6,1,2])")
        self.assertTrue(min([5,3,4],[6,1,2]) == [5,3,4] , "min([5,3,4],[6,1,2])")
 
        for y in iter(o.x):
            tst.append(y)
        self.assertTrue(tst, [1,2,3])
        tst = []
        try:
            for y in o.x:
                tst.append(y)
            self.assertTrue(tst, [1,2,3])
            ])
 
        self.assertTrue(isinstance(1.0, float), "1.0 should be instance of float")
 
    def testOrdChr(self):

src/p/y/pyjs-HEAD/examples/libtest/ListTest.py   pyjs(Download)
    def testSliceGet(self):
        value = [0, 1, 2, 3, 4]
 
        self.assertTrue(value[-1] is 4)
        self.assertTrue(value[1] is 1)
        self.assertTrue(value[4] is 4)
        self.assertTrue(value[-3] is 2)
    def testSliceRange(self):
        value = [0, 1, 2, 3, 4]
 
        self.assertTrue(value[1:3][0] is 1)
        self.assertTrue(value[1:3][1] is 2)

src/p/y/pyjs-HEAD/examples/libtest/BoolTest.py   pyjs(Download)
    def testBaseTypes(self):
        # meta test first
        self.assertTrue(True)
        self.assertFalse(False)
 
        # booleans
        self.assertTrue(bool(True))
        self.assertFalse(bool(False))
        self.assertTrue(True == True)
 
        # ints
        self.assertTrue(bool(1))
        self.assertFalse(bool(0))
        self.assertTrue(1)

src/p/y/pyjs-HEAD/examples/libtest/StringTest.py   pyjs(Download)
    def testBasestring(self):
        s = 'A string'
        self.assertTrue(isinstance(s, str), "isinstance(s, str)")
        self.assertTrue(isinstance(s, basestring), "isinstance(s, basestring)")
 
    def testIsAlnum(self):
        self.assertTrue("abc".isalnum())
        self.assertTrue("0bc".isalnum())
        self.assertFalse(".?abc".isalnum())
        self.assertFalse(" 0bc".isalnum())
 
    def testIsAlpha(self):
        self.assertTrue("abc".isalpha())

src/p/y/pyjs-HEAD/examples/libtest/ArgsTest.py   pyjs(Download)
        except TypeError, t:
            exc_raised = True
        self.assertTrue(exc_raised, "TypeError 'c' unexpected arg not raised")
 
    def testNaming5(self):
        except TypeError, t:
            exc_raised = True
        self.assertTrue(exc_raised, "TypeError 'ftest() takes exactly 2 arguments (0 given)' not raised")
 
    def testSimpleCall(self):
        # weird one: a string is a sequence, so it gets away with being
        # called on its own as *args! eeugh.
        self.assertTrue(called,
                    "exception not expected but function called:" + repr(res) + repr(exc))
        self.assertEquals(res, ("1", "2", "3"))
    def testKwArgsInherit(self):
 
        c = KwArgs(x=5, y=6)
        self.assertTrue(hasattr(c, 'kwargs'))
        kwa = getattr(c, 'kwargs', None)
        try:
            c = Kwargs2(x=5, y=6)
            self.assertTrue(hasattr(c, 'kwargs'))
            kwa = getattr(c, 'kwargs', None)
            if kwa:

src/p/y/pyjs-HEAD/examples/libtest/ReModuleTest.py   pyjs(Download)
    def matchTest(self, msg, pat, flags, string, groups, span):
        r = re.compile(pat, flags)
        m = r.match(string)
        if groups is None:
            self.assertTrue(m is None, "%s: None expected" % msg)
            return
        self.assertTrue(m is not None, "%s: Unexpected None" % msg)
        self.assertTrue(len(m.groups()) == len(groups)-1, "%s: len(m.groups()) = %s != %s" % (msg, len(m.groups()), len(groups)-1))
        self.assertEqual(m.start(), span[0], "%s: start = %d != %d" % (msg, m.start(), span[0]))
        self.assertEqual(m.end(), span[1], "%s: end = %d != %d" % (msg, m.end(), span[1]))
        self.assertTrue(m.span() == span, "%s: span = %r != %r" % (msg, m.span(), span[1]))
 
    def searchTest(self, msg, pat, flags, string, groups, span):
        r = re.compile(pat, flags)
        m = r.search(string)
        if groups is None:
            self.assertTrue(m is None, "%s: None expected" % msg)

src/p/y/pyjs-HEAD/examples/libtest/FunctionTest.py   pyjs(Download)
        h = Handler(5)
        f = lambda x: h.handle(x)
        self.assertTrue(f(5))
        self.assertFalse(f(4))
 
        except:
            self.fail("Bug #572 Callable()() __call__ not supported")
        self.assertTrue(callable(Callable))
        self.assertTrue(
            callable(Callable()),
            "Bug #572 callable(Callable()) __call__ not supported",
        )
 
    def testProcedure(self):
        self.assertTrue(aFunctionReturningNone() is None,
    def testProcedure(self):
        self.assertTrue(aFunctionReturningNone() is None,
                        "Function should return None")
        self.assertTrue(aProcedure() is None,
                        "Procedures should always return None")

src/p/y/pyjs-HEAD/examples/libtest/ExceptionTest.py   pyjs(Download)
    def testTypeError(self):
        try:
            raise TypeError("fred")
        except:
            self.assertTrue(True, "the exception should have happened")
            return
        self.assertTrue(False, "the exception should have happened")
    def testExceptionOrdTrigger(self):
        try:
            x = ord(5) # shouldn't be a number
        except:
            self.assertTrue(True, "the exception should have happened")
            return
        self.assertTrue(False, "mustn't be able to do ord() on a number")
    def testExceptionOrdNoTrigger(self):
        try:
            x = ord("5")
        except:
            self.assertTrue(False, "the exception shouldn't have happened")

src/p/y/pyjs-HEAD/examples/libtest/GeneratorTest.py   pyjs(Download)
            self.fail("Exception expected (1)")
        except TypeError, e:
            self.assertTrue(e, 'test1')
        try:
            r = g.next()
            self.fail("StopIteration expected (1)")
        except StopIteration:
            self.assertTrue(True)
            self.fail("Exception expected (2)")
        except TypeError, e:
            self.assertTrue(e, 'test2')
        try:
            r = g.next()
            self.fail("StopIteration expected (2)")
        except StopIteration:
            self.assertTrue(True)
            self.fail("Exception expected (3)")
        except TypeError, e:
            self.assertTrue(e, 'test3')
 
        g = fn()

src/p/y/pyjs-HEAD/examples/libtest/DictTest.py   pyjs(Download)
 
        v = {(1, 2): 5, 1: 1, (1, 1): 4, (2,): 3}
        self.assertTrue(d == v, "%r == %r" % (d, v))
 
        d = {}
 
        item = d.popitem()
        self.assertTrue(item == ('a',1) or item == ('c',3), "popped invalid item %s" % str(item))
 
        item = d.popitem()

  1 | 2 | 3  Next