~pythoneers/ubuntu/lucid/python-apt/ltsppa

« back to all changes in this revision

Viewing changes to tests/refcount.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt, Julian Andres Klode, Michael Vogt
  • Date: 2010-03-23 20:01:22 UTC
  • mfrom: (2.3.12 sid)
  • Revision ID: james.westby@ubuntu.com-20100323200122-3t1elea9fbjqn760
Tags: 0.7.94.2ubuntu1
Updated to the 0.7.9x series (FFe LP: #531518), this
brings us python3 support and a more PEP08 conform
API

[ Julian Andres Klode ]
* python/generic.cc:
  - Fix a memory leak when using old attribute names.
* debian/control:
  - Change priority to standard, keep -doc and -dev on optional.

[ Michael Vogt ]
* apt/cache.py:
  - make cache open silent by default (use apt.progress.base.OpProgress)
* tests/data/aptsources_ports/sources.list:
  - fix ports test-data
* debian/control
  - build against XS-Python-Versions: 2.6, 3.1
* tests/test_apt_cache.py:
  - add simple test for basic cache/dependency iteration
* apt/__init__.py:
  - only show deprecation warnings if PYTHON_APT_DEPRECATION_WARNINGS
    is set in the environment. While we do want to have the new API its
    not feasible to port all apps in the lucid timeframe. Once lucid
    is released we turn the warnings on by default again

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python-dbg
2
 
 
3
 
from pprint import pprint, pformat
4
 
import apt
5
 
import sys
6
 
import gc
7
 
import difflib
8
 
 
9
 
# get initial cache
10
 
print sys.gettotalrefcount()
11
 
progress= apt.progress.OpTextProgress()
12
 
c = apt.Cache(progress)
13
 
print "refcount after first cache instance: ", sys.gettotalrefcount()
14
 
 
15
 
# test open()
16
 
c.open(progress)
17
 
print "refcount after cache open: ", sys.gettotalrefcount()
18
 
#pprint(sys.getobjects(10))
19
 
 
20
 
c.open(apt.progress.OpProgress())
21
 
print "refcount after seconf cache open: ", sys.gettotalrefcount()
22
 
#pprint(sys.getobjects(10))
23
 
 
24
 
# FIXME: find a way to get a efficient diff
25
 
#before = gc.get_objects()
26
 
#c.open(apt.progress.OpProgress())
27
 
#after = gc.get_objects()
28
 
 
29
 
 
30
 
# test update()
31
 
print "refcount before cache.update(): ", sys.gettotalrefcount()
32
 
c.update()
33
 
gc.collect()
34
 
print "refcount after cache.update(): ", sys.gettotalrefcount()
35
 
c.update()
36
 
gc.collect()
37
 
print "refcount after second cache.update(): ", sys.gettotalrefcount()
38
 
#pprint(sys.getobjects(20))
39
 
 
40
 
 
41
 
# test install()
42
 
c.open(apt.progress.OpProgress())
43
 
gc.collect()
44
 
print "refcount before cache['hello'].markInstall(): ", sys.gettotalrefcount()
45
 
c["hello"].markInstall()
46
 
c.commit(apt.progress.FetchProgress(), apt.progress.InstallProgress())
47
 
gc.collect()
48
 
print "refcount after: ", sys.gettotalrefcount()
49
 
c.open(apt.progress.OpProgress())
50
 
c["hello"].markDelete()
51
 
c.commit(apt.progress.FetchProgress(), apt.progress.InstallProgress())
52
 
gc.collect()
53
 
print "refcount after: ", sys.gettotalrefcount()
54
 
pprint(sys.getobjects(10))