view test/test_anypy.py @ 6548:de5f5f9c02f2

Fix spurious content-ty on 304; xfail css Cache-Control Using wsgiref.validate.validator to verify http/wsgi responses. It discovered that a 304 was returning a content-type header but shouldn't. Fixed that. For some unknown reason I can't reproduce on my devel platform, travis-ci is throwing: > self.assertEqual(f.headers['Cache-Control'], 'public, max-age=4838400') E AssertionError: 'public, max-age=3600' != 'public, max-age=4838400' E - public, max-age=3600 E ? ^ E + public, max-age=4838400 E ? ++ ^^ in test_liveserver test_cache_control_css. I have no idea why this is happening. The 3600 value isn't in the code base or tracker template that I see. While I was trying to figure out if the wsgi server later was an issue, I came across the validator. Maybe it will throw some light on this error?
author John Rouillard <rouilj@ieee.org>
date Thu, 09 Dec 2021 20:11:58 -0500
parents e4db9d0b85c7
children c65e0a725c88
line wrap: on
line source

"""Random tests for anypy modules"""


import unittest
from roundup.anypy.strings import repr_export, eval_import

import sys
_py3 = sys.version_info[0] > 2

class StringsTest(unittest.TestCase):

    def test_import_params(self):
        """ issue2551170 - handle long int in history/journal
            params tuple
        """
        # python2 export with id as number
        val = eval_import("('issue', 2345L, 'status')")
        self.assertSequenceEqual(val, ('issue', 2345, 'status'))

        # python3 export with id as number
        val = eval_import("('issue', 2345, 'status')")
        self.assertSequenceEqual(val, ('issue', 2345, 'status'))

        # python2 or python3 export with id as string
        val = eval_import("('issue', '2345', 'status')")
        self.assertSequenceEqual(val, ('issue', '2345', 'status'))

    def test_export_params(self):
        """ issue2551170 - handle long int in history/journal
            params tuple
        """
        # python2 export with id as number
        if _py3:
            val = repr_export(('issue', 2345, 'status'))
            self.assertEqual(val, "('issue', 2345, 'status')")
        else:
            val = repr_export(('issue', long(2345), 'status'))
            self.assertEqual(val, "('issue', 2345L, 'status')")

        # python2 or python3 export with id as string
        val = repr_export(('issue', '2345', 'status'))
        self.assertEqual(val, "('issue', '2345', 'status')")
            

Roundup Issue Tracker: http://roundup-tracker.org/