diff MoinMoin/request/_tests/test_request.py @ 2893:408b301a5e44

emit_http_headers tests: fixed (never call functions with side-effects in assert, because they get executed twice)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 20 Oct 2007 18:19:48 +0200
parents 863060b2cfc5
children f009ead62bfd
line wrap: on
line diff
--- a/MoinMoin/request/_tests/test_request.py	Sat Oct 20 17:51:48 2007 +0200
+++ b/MoinMoin/request/_tests/test_request.py	Sat Oct 20 18:19:48 2007 +0200
@@ -110,35 +110,34 @@
 
 
 class TestHTTPHeaders(object):
-    std_headers = ['Status: 200 OK', 'Content-type: text/html; charset=UTF-8', ]
+    std_headers = ['Status: 200 OK', 'Content-type: text/html; charset=%s' % config.charset]
     
     def setup_method(self, method):
         self.request.sent_headers = False
         
     def testAutoAddStdHeaders(self):
         """ test if the usual headers get auto-added if not specified """
-        print self.request.sent_headers
-        assert self.request.emit_http_headers(testing=True) == self.std_headers
+        headers_out = self.request.emit_http_headers(testing=True)
+        assert headers_out == self.std_headers
 
     def testHeadersOnlyOnce(self):
         """ test if trying to call emit_http_headers multiple times raises an exception """
-        print self.request.sent_headers
         self.request.emit_http_headers(testing=True)
         py.test.raises(HeadersAlreadySentException, self.request.emit_http_headers, [], {'testing': True})
 
     def testDuplicateHeadersIgnored(self):
         """ test if duplicate headers get ignored """
-        print self.request.sent_headers
         headers_in = self.std_headers + ['Status: 500 Server Error']
         headers_expected = self.std_headers
-        assert self.request.emit_http_headers(headers_in, testing=True) == headers_expected
+        headers_out = self.request.emit_http_headers(headers_in, testing=True)
+        assert headers_out == headers_expected
 
     def testListHeaders(self):
         """ test if header values get merged into a list for headers supporting it """
-        print self.request.sent_headers
         headers_in = self.std_headers + ['Vary: aaa', 'vary: bbb']
         headers_expected = self.std_headers + ['Vary: aaa, bbb']
-        assert self.request.emit_http_headers(headers_in, testing=True) == headers_expected
+        headers_out = self.request.emit_http_headers(headers_in, testing=True)
+        assert headers_out == headers_expected
 
 coverage_modules = ['MoinMoin.request']