Skip to content

Commit

Permalink
Fix CachingPolicyNodeAdapterTests on Python 2.7.
Browse files Browse the repository at this point in the history
On Python 2.7 this input:

```
    predicate="python:object.getPortalTypeName() == 'Foo'"
    private="False" proxy_revalidate="False" public="False" vary=""/>
```

gets transformed to this output:

```
    predicate="python:object.getPortalTypeName() == 'Foo'" private="False"
    proxy_revalidate="False" public="False" vary=""/>
```

On Python 3 it would be the other way around.

So use the actual output, and then the transform makes no changes.
  • Loading branch information
mauritsvanrees committed Sep 20, 2023
1 parent 996a6c2 commit dd33a1a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Products/CMFCore/exportimport/tests/test_cachingpolicymgr.py
Expand Up @@ -13,6 +13,7 @@
"""Caching policy manager xml adapter and setup handler unit tests.
"""

import six
import unittest

from OFS.Folder import Folder
Expand Down Expand Up @@ -49,6 +50,19 @@
</object>
"""

# On Python 2.7 the tests fail if we use '&#x27;'.
_CPM_BODY_27 = b"""\
<?xml version="1.0" encoding="utf-8"?>
<object name="caching_policy_manager" meta_type="CMF Caching Policy Manager">
<caching-policy name="foo_policy" enable_304s="False" etag_func=""
last_modified="True" max_age_secs="600" mtime_func="object/modified"
must_revalidate="False" no_cache="False" no_store="False"
no_transform="False"
predicate="python:object.getPortalTypeName() == 'Foo'" private="False"
proxy_revalidate="False" public="False" vary=""/>
</object>
"""


class CachingPolicyNodeAdapterTests(NodeAdapterTestCase, unittest.TestCase):

Expand Down Expand Up @@ -83,7 +97,10 @@ def _populate(self, obj):

def setUp(self):
self._obj = CachingPolicyManager()
self._BODY = _CPM_BODY
if six.PY3:
self._BODY = _CPM_BODY
else:
self._BODY = _CPM_BODY_27


class _CachingPolicyManagerSetup(BaseRegistryTests):
Expand Down

0 comments on commit dd33a1a

Please sign in to comment.