summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2012-01-12 18:29:37 +0000
committerGiampaolo Rodola <g.rodola@gmail.com>2012-01-12 18:29:37 +0000
commitd6393360de7e9ac77c11d37370fe879ea8e82c09 (patch)
tree61fcdd2c0450e2851e18ceea7df78dc504cfd6a1
parent81145952a4e26ad0ddfd6e4f502a95ee8f4ae4e5 (diff)
downloadpysendfile-d6393360de7e9ac77c11d37370fe879ea8e82c09.tar.gz
provide a -k cmdline option for the test suite to avoid removing the big file created on startup
-rw-r--r--test/test_sendfile.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/test/test_sendfile.py b/test/test_sendfile.py
index 223dcc5..0454e0a 100644
--- a/test/test_sendfile.py
+++ b/test/test_sendfile.py
@@ -3,6 +3,13 @@
# $Id$
#
+"""
+pysendfile test suite; works with both python 2.x and 3.x (no need
+to run 2to3 tool first).
+Accepts a -k cmdline option to avoid removing the big file created
+during tests.
+"""
+
from __future__ import with_statement
import unittest
@@ -16,6 +23,7 @@ import errno
import time
import atexit
import warnings
+import optparse
import sendfile
@@ -508,20 +516,23 @@ class TestLargeFile(unittest.TestCase):
def test_main():
+ parser = optparse.OptionParser()
+ parser.add_option('-k', '--keepfile', action="store_true", default=False,
+ help="do not remove test big file on exit")
+ options, args = parser.parse_args()
+ if not options.keepfile:
+ atexit.register(lambda: safe_remove(TESTFN3))
def cleanup():
safe_remove(TESTFN)
safe_remove(TESTFN2)
- safe_remove(TESTFN3)
atexit.register(cleanup)
test_suite = unittest.TestSuite()
test_suite.addTest(unittest.makeSuite(TestSendfile))
if has_large_file_support():
- # XXX
- #test_suite.addTest(unittest.makeSuite(TestLargeFile))
- pass
+ test_suite.addTest(unittest.makeSuite(TestLargeFile))
else:
atexit.register(warnings.warn, "large files unsupported", RuntimeWarning)
cleanup()