PyUT: Add a fake apt-cache for testing purposes.
authorDidier Raboud <odyx@debian.org>
Tue, 22 May 2012 08:44:43 +0000 (10:44 +0200)
committerDidier Raboud <odyx@debian.org>
Tue, 22 May 2012 09:25:06 +0000 (11:25 +0200)
debian/rules
test/apt-cache [new file with mode: 0755]

index ec2bbff0babc399cba50f6594a6ef1f5862534bb..b5690ddb07d18e054b0a927cc06af50adeba29ac 100755 (executable)
@@ -54,7 +54,7 @@ test-python2.6:
        # Tests are not backported to python2.6, sorry.
 
 test-python%:
-       PYTHONPATH=. python$* test/test_lsb_release.py -vv
+       PATH=test/:$${PATH} PYTHONPATH=. python$* test/test_lsb_release.py -vv
        PYTHONPATH=. python$* test/test_initdutils.py -vv
 
 override_dh_python2:
diff --git a/test/apt-cache b/test/apt-cache
new file mode 100755 (executable)
index 0000000..f6cc88f
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/python
+
+# Fake apt-cache python script to emulate policy output for test usage
+
+# Python3-compatible print() function
+from __future__ import print_function
+
+import sys
+
+if len(sys.argv) <= 1 or sys.argv[1] != 'policy':
+       sys.exit("Shall only be run with exactly one argument: 'policy'")
+
+print("Package files:")
+print(" 100 /var/lib/dpkg/status")
+print("     release a=now")