ValueError in tests.core.test_util.test_diskfree
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
holland-backup |
Fix Released
|
Medium
|
Andrew Garner | ||
1.1 |
Fix Released
|
Medium
|
Andrew Garner |
Bug Description
Using amsterdam (current) on Fedora 14 64bit:
[wdierkes@
New python executable in /home/wdierkes/
Installing setuptools.
[INFO] Installed holland-core.
[INFO] Installing holland plugins
[INFO] Installed plugin holland.lib.common
[INFO] Installed plugin holland.lib.mysql
[INFO] Installed plugin holland.lib.lvm
[INFO] Installed plugin holland.
[INFO] Installed plugin holland.
[INFO] Installed plugin holland.
[INFO] Starting shell in virtual environment /bin/bash - use ctrl-d to exit
[holland-test]% nosetests --verbosity 3
nose.config: INFO: Set working dir to /home/wdierkes/
nose.config: INFO: Working directory /home/wdierkes/
nose.plugins.cover: ERROR: Coverage not available: unable to import coverage module
... snip ok tests ...
tests.core.
=======
ERROR: tests.core.
-------
Traceback (most recent call last):
File "/usr/lib/
self.
File "/home/
actual_bytes = int(commands.
ValueError: invalid literal for int() with base 10: '80%'
-------
Ran 96 tests in 38.849s
FAILED (errors=1)
Changed in holland-backup: | |
milestone: | none → 1.1.0a2 |
description: | updated |
Changed in holland-backup: | |
assignee: | nobody → Andrew Garner (muzazzi) |
importance: | Undecided → Medium |
status: | New → Fix Committed |
Changed in holland-backup: | |
status: | Fix Committed → Fix Released |
The offending test is:
#XXX: df output isn't 100% portable getoutput( real_cmd) .strip( )) equals( path.disk_ free("/ "), actual_bytes)
#XXX: race condition between running df and disk_free()
def test_diskfree():
import commands
real_cmd = "df -B1 / | tail -n +2 | awk '{ print $4; }'"
actual_bytes = int(commands.
assert_
The output of 'real_cmd' on Fedora linux 14 is:
[holland-test]% df -B1 / | tail -n +2 | awk '{ print $4; }'
80%
The leading line is not the problem though, it is the '%':
>>> commands. getoutput( real_cmd) .strip( )
'80%'
>>> int('80%')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '80%'
>>> int('80')
80
Adding an additional ".rstrip('%')" would solve this problem... though it isn't exactly elegant:
>>> actual_bytes = int(commands. getoutput( real_cmd) .strip( ).rstrip( '%'))
>>> actual_bytes
80
The problem, as noted in the 'XXX' comments is that this test isn't very portable. The same 'real_cmd' on Darwin/OSX is:
derks-macbook [~] $ df -B1 / | tail -n +2 | awk '{ print $4; }'
df: illegal option -- B
usage: df [-b | -H | -h | -k | -m | -g | -P] [-ailn] [-T type] [-t type] [filesystem ...]