diff options
author | maluke <devnull@localhost> | 2008-05-28 10:18:39 +0000 |
---|---|---|
committer | maluke <devnull@localhost> | 2008-05-28 10:18:39 +0000 |
commit | c7650b9216fc51958661ac9776f8e5d92ad2a189 (patch) | |
tree | becc4f0d7e5fbced474a8854a3bcdf6aed39aa4a | |
parent | 17d0f5861607738f25ee4bb119cbcea2245dec9d (diff) | |
download | paste-c7650b9216fc51958661ac9776f8e5d92ad2a189.tar.gz |
Fixed test suite on Windows (also disabled CGI tests as they shouldn't even work)
-rw-r--r-- | paste/session.py | 7 | ||||
-rw-r--r-- | paste/util/doctest24.py | 4 | ||||
-rw-r--r-- | paste/util/quoting.py | 2 | ||||
-rw-r--r-- | tests/test_cgiapp.py | 51 | ||||
-rw-r--r-- | tests/test_exceptions/test_formatter.py | 6 |
5 files changed, 36 insertions, 34 deletions
diff --git a/paste/session.py b/paste/session.py index 93a1c23..5f57b92 100644 --- a/paste/session.py +++ b/paste/session.py @@ -30,6 +30,7 @@ import os import md5 import datetime import threading +import tempfile try: import cPickle @@ -79,7 +80,7 @@ class SessionFactory(object): session_class=None, session_expiration=60*12, # in minutes **session_class_kw): - + self.created = False self.used = False self.environ = environ @@ -171,7 +172,7 @@ cleanup_cycle = datetime.timedelta(seconds=15*60) #15 min class FileSession(object): - def __init__(self, sid, create=False, session_file_path='/tmp', + def __init__(self, sid, create=False, session_file_path=tempfile.gettempdir(), chmod=None, expiration=2880, # in minutes: 48 hours ): @@ -295,7 +296,7 @@ def make_session_middleware( session_expiration: The time each session lives, in minutes. This controls - the cookie expiration. Default 12 hours. + the cookie expiration. Default 12 hours. expiration: The time each session lives on disk. Old sessions are diff --git a/paste/util/doctest24.py b/paste/util/doctest24.py index 0a13d77..28849ed 100644 --- a/paste/util/doctest24.py +++ b/paste/util/doctest24.py @@ -1319,13 +1319,13 @@ class DocTestRunner: __LINECACHE_FILENAME_RE = re.compile(r'<doctest ' r'(?P<name>[\w\.]+)' r'\[(?P<examplenum>\d+)\]>$') - def __patched_linecache_getlines(self, filename): + def __patched_linecache_getlines(self, filename, module_globals=None): m = self.__LINECACHE_FILENAME_RE.match(filename) if m and m.group('name') == self.test.name: example = self.test.examples[int(m.group('examplenum'))] return example.source.splitlines(True) else: - return self.save_linecache_getlines(filename) + return self.save_linecache_getlines(filename)#?, module_globals) def run(self, test, compileflags=None, out=None, clear_globs=True): """ diff --git a/paste/util/quoting.py b/paste/util/quoting.py index cd87f2d..9b67596 100644 --- a/paste/util/quoting.py +++ b/paste/util/quoting.py @@ -50,7 +50,7 @@ def html_unquote(s, encoding=None): >>> html_unquote('<hey you>') u'<hey\xa0you>' >>> html_unquote('') - '' + u'' >>> html_unquote('&blahblah;') u'&blahblah;' >>> html_unquote('\xe1\x80\xa9') diff --git a/tests/test_cgiapp.py b/tests/test_cgiapp.py index 8a0dfcf..8b96e43 100644 --- a/tests/test_cgiapp.py +++ b/tests/test_cgiapp.py @@ -1,34 +1,35 @@ import os +import sys import py.test from paste.cgiapp import CGIApplication, CGIError from paste.fixture import * data_dir = os.path.join(os.path.dirname(__file__), 'cgiapp_data') +if sys.platform != 'win32': # these CGI scripts can't work on Windows + def test_ok(): + app = TestApp(CGIApplication({}, script='ok.cgi', path=[data_dir])) + res = app.get('') + assert res.header('content-type') == 'text/html; charset=UTF-8' + assert res.full_status == '200 Okay' + assert 'This is the body' in res -def test_ok(): - app = TestApp(CGIApplication({}, script='ok.cgi', path=[data_dir])) - res = app.get('') - assert res.header('content-type') == 'text/html; charset=UTF-8' - assert res.full_status == '200 Okay' - assert 'This is the body' in res - -def test_form(): - app = TestApp(CGIApplication({}, script='form.cgi', path=[data_dir])) - res = app.post('', params={'name': 'joe'}, - upload_files=[('up', 'file.txt', 'x'*10000)]) - assert 'file.txt' in res - assert 'joe' in res - assert 'x'*10000 in res + def test_form(): + app = TestApp(CGIApplication({}, script='form.cgi', path=[data_dir])) + res = app.post('', params={'name': 'joe'}, + upload_files=[('up', 'file.txt', 'x'*10000)]) + assert 'file.txt' in res + assert 'joe' in res + assert 'x'*10000 in res + + def test_error(): + app = TestApp(CGIApplication({}, script='error.cgi', path=[data_dir])) + py.test.raises(CGIError, "app.get('', status=500)") + + def test_stderr(): + app = TestApp(CGIApplication({}, script='stderr.cgi', path=[data_dir])) + res = app.get('', expect_errors=True) + assert res.status == 500 + assert 'error' in res + assert 'some data' in res.errors -def test_error(): - app = TestApp(CGIApplication({}, script='error.cgi', path=[data_dir])) - py.test.raises(CGIError, "app.get('', status=500)") - -def test_stderr(): - app = TestApp(CGIApplication({}, script='stderr.cgi', path=[data_dir])) - res = app.get('', expect_errors=True) - assert res.status == 500 - assert 'error' in res - assert 'some data' in res.errors - diff --git a/tests/test_exceptions/test_formatter.py b/tests/test_exceptions/test_formatter.py index 01b4d04..2fe4528 100644 --- a/tests/test_exceptions/test_formatter.py +++ b/tests/test_exceptions/test_formatter.py @@ -93,7 +93,7 @@ def test_trim(): except: result = format(f, trim_source_paths=[(current, '.')]) assert current not in result - assert '/test_formatter.py' in result + assert ('%stest_formatter.py' % os.sep) in result, ValueError(repr(result)) else: assert 0 @@ -148,7 +148,7 @@ def test_hide_after(): # A little whitespace to keep this line out of the # content part of the report - + hide, 'reset', raise_error) except: @@ -159,7 +159,7 @@ def test_hide_after(): assert 'raise_error' in result else: assert 0 - + def test_hide_before(): for f in formats: try: |