p!ranha?
Server IP : 103.169.32.36  /  Your IP : 216.73.217.13
Web Server : Apache
System : Linux web.dpmptsp 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 5.6.40
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/doc/python-pycurl-7.19.0/tests/

Upload File :
Curr3nt_D!r [ Writeable ] D0cum3nt_r0Ot [ Writeable ]

 
Command :
Current File : /usr/share/doc/python-pycurl-7.19.0/tests/test_internals.py
#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
# vi:ts=4:et
# $Id: test_internals.py,v 1.17 2003/05/01 16:48:54 mfx Exp $

#
# a simple self-test
#

try:
    # need Python 2.2 or better for garbage collection
    from gc import get_objects
    import gc
    del get_objects
    gc.enable()
except ImportError:
    gc = None
import copy, os, sys
from StringIO import StringIO
try:
    import cPickle
except ImportError:
    cPickle = None
try:
    import pickle
except ImportError:
    pickle = None

# update sys.path when running in the build directory
from util import get_sys_path
sys.path = get_sys_path()

import pycurl
from pycurl import Curl, CurlMulti


class opts:
    verbose = 1

if "-q" in sys.argv:
    opts.verbose = opts.verbose - 1


print "Python", sys.version
print "PycURL %s (compiled against 0x%x)" % (pycurl.version, pycurl.COMPILE_LIBCURL_VERSION_NUM)
print "PycURL version info", pycurl.version_info()
print "  %s, compiled %s" % (pycurl.__file__, pycurl.COMPILE_DATE)


# /***********************************************************************
# // test misc
# ************************************************************************/

if 1:
    c = Curl()
    assert c.URL is pycurl.URL
    del c


# /***********************************************************************
# // test handles
# ************************************************************************/

# remove an invalid handle: this should fail
if 1:
    m = CurlMulti()
    c = Curl()
    try:
        m.remove_handle(c)
    except pycurl.error:
        pass
    else:
        assert 0, "internal error"
    del m, c


# remove an invalid but closed handle
if 1:
    m = CurlMulti()
    c = Curl()
    c.close()
    m.remove_handle(c)
    del m, c


# add a closed handle: this should fail
if 1:
    m = CurlMulti()
    c = Curl()
    c.close()
    try:
        m.add_handle(c)
    except pycurl.error:
        pass
    else:
        assert 0, "internal error"
    m.close()
    del m, c


# add a handle twice: this should fail
if 1:
    m = CurlMulti()
    c = Curl()
    m.add_handle(c)
    try:
        m.add_handle(c)
    except pycurl.error:
        pass
    else:
        assert 0, "internal error"
    del m, c


# add a handle on multiple stacks: this should fail
if 1:
    m1 = CurlMulti()
    m2 = CurlMulti()
    c = Curl()
    m1.add_handle(c)
    try:
        m2.add_handle(c)
    except pycurl.error:
        pass
    else:
        assert 0, "internal error"
    del m1, m2, c


# move a handle
if 1:
    m1 = CurlMulti()
    m2 = CurlMulti()
    c = Curl()
    m1.add_handle(c)
    m1.remove_handle(c)
    m2.add_handle(c)
    del m1, m2, c


# /***********************************************************************
# // test copying and pickling - copying and pickling of
# // instances of Curl and CurlMulti is not allowed
# ************************************************************************/

if 1 and copy:
    c = Curl()
    m = CurlMulti()
    try:
        copy.copy(c)
    except copy.Error:
        pass
    else:
        assert 0, "internal error - copying should fail"
    try:
        copy.copy(m)
    except copy.Error:
        pass
    else:
        assert 0, "internal error - copying should fail"

if 1 and pickle:
    c = Curl()
    m = CurlMulti()
    fp = StringIO()
    p = pickle.Pickler(fp, 1)
    try:
        p.dump(c)
    except pickle.PicklingError:
        pass
    else:
        assert 0, "internal error - pickling should fail"
    try:
        p.dump(m)
    except pickle.PicklingError:
        pass
    else:
        assert 0, "internal error - pickling should fail"
    del c, m, fp, p

if 1 and cPickle:
    c = Curl()
    m = CurlMulti()
    fp = StringIO()
    p = cPickle.Pickler(fp, 1)
    try:
        p.dump(c)
    except cPickle.PicklingError:
        pass
    else:
        assert 0, "internal error - pickling should fail"
    try:
        p.dump(m)
    except cPickle.PicklingError:
        pass
    else:
        assert 0, "internal error - pickling should fail"
    del c, m, fp, p


# /***********************************************************************
# // test refcounts
# ************************************************************************/

# basic check of reference counting (use a memory checker like valgrind)
if 1:
    c = Curl()
    m = CurlMulti()
    m.add_handle(c)
    del m
    m = CurlMulti()
    c.close()
    del m, c

# basic check of cyclic garbage collection
if 1 and gc:
    gc.collect()
    c = Curl()
    c.m = CurlMulti()
    c.m.add_handle(c)
    # create some nasty cyclic references
    c.c = c
    c.c.c1 = c
    c.c.c2 = c
    c.c.c3 = c.c
    c.c.c4 = c.m
    c.m.c = c
    c.m.m = c.m
    c.m.c = c
    # delete
    gc.collect()
    flags = gc.DEBUG_COLLECTABLE | gc.DEBUG_UNCOLLECTABLE | gc.DEBUG_OBJECTS
    if opts.verbose >= 1:
        flags = flags | gc.DEBUG_STATS
    gc.set_debug(flags)
    gc.collect()
    ##print gc.get_referrers(c)
    ##print gc.get_objects()
    if opts.verbose >= 1:
        print "Tracked objects:", len(gc.get_objects())
    # The `del' below should delete these 4 objects:
    #   Curl + internal dict, CurlMulti + internal dict
    del c
    gc.collect()
    if opts.verbose >= 1:
        print "Tracked objects:", len(gc.get_objects())

if 1:
    # Ensure that the refcounting error in "reset" is fixed:
    for i in xrange(100000):
        c = Curl()
        c.reset()

# /***********************************************************************
# // done
# ************************************************************************/

print "All tests passed."
N4m3
5!z3
L45t M0d!f!3d
0wn3r / Gr0up
P3Rm!55!0n5
0pt!0n5
..
--
December 20 2023 04:36:12
0 / 0
0755
test.py
1.907 KB
April 10 2007 13:25:17
0 / 0
0644
test_cb.py
0.677 KB
April 21 2003 18:46:10
0 / 0
0644
test_debug.py
0.332 KB
April 21 2003 18:46:10
0 / 0
0644
test_ftp.py
0.282 KB
August 24 2006 07:36:03
0 / 0
0644
test_getinfo.py
1.386 KB
May 01 2003 19:35:01
0 / 0
0644
test_gtk.py
2.669 KB
March 30 2005 12:05:50
0 / 0
0644
test_internals.py
5.478 KB
November 05 2016 15:10:52
0 / 0
0644
test_memleak.py
1.1 KB
May 01 2003 16:48:54
0 / 0
0644
test_multi.py
0.66 KB
March 11 2005 13:24:45
0 / 0
0644
test_multi2.py
1.705 KB
April 10 2007 13:26:45
0 / 0
0644
test_multi3.py
2.02 KB
March 11 2005 13:24:45
0 / 0
0644
test_multi4.py
1.367 KB
March 11 2005 13:24:45
0 / 0
0644
test_multi5.py
1.438 KB
March 11 2005 13:24:45
0 / 0
0644
test_multi6.py
1.5 KB
March 11 2005 13:24:45
0 / 0
0644
test_multi_socket.py
1.879 KB
November 10 2006 15:03:05
0 / 0
0644
test_multi_socket_select.py
2.39 KB
June 11 2008 18:11:46
0 / 0
0644
test_multi_timer.py
1.708 KB
November 10 2006 12:25:29
0 / 0
0644
test_multi_vs_thread.py
5.638 KB
April 12 2005 03:39:01
0 / 0
0644
test_post.py
0.575 KB
August 05 2008 20:43:37
0 / 0
0644
test_post2.py
0.522 KB
March 03 2005 10:00:40
0 / 0
0644
test_post3.py
0.785 KB
June 21 2004 11:24:18
0 / 0
0644
test_reset.py
2.19 KB
November 05 2016 15:10:52
0 / 0
0644
test_share.py
0.697 KB
June 13 2006 19:04:44
0 / 0
0644
test_socketopen.py
0.43 KB
August 22 2008 17:14:40
0 / 0
0644
test_stringio.py
0.462 KB
April 21 2003 18:46:11
0 / 0
0644
test_write_abort.py
0.647 KB
November 05 2016 15:10:52
0 / 0
0644
test_xmlrpc.py
0.727 KB
April 21 2003 18:46:11
0 / 0
0644
util.py
0.927 KB
April 21 2003 18:46:11
0 / 0
0644
util.pyc
0.98 KB
November 05 2016 15:10:53
0 / 0
0644