Skip to content

Commit

Permalink
fix broken tests en P4
Browse files Browse the repository at this point in the history
  • Loading branch information
duchenean committed May 29, 2024
1 parent fe82eaa commit f811693
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 45 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,21 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Env
run: |
mkdir -p -m 777 /tmp/appy/
sudo add-apt-repository ppa:libreoffice/ppa -y
sudo apt update -qq -y
sudo apt-get install -qq -y libreoffice libreoffice-script-provider-python
mkdir -p buildout-cache/{eggs,downloads}
- name: Set up pyenv and Python
uses: "gabrielfalcao/pyenv-action@v14"
with:
default: "${{ matrix.python }}"
- name: Setup Env
- name: Setup Python env
run: |
pip install --upgrade pip
pip install -r requirements-${{matrix.plone}}.txt
pip install -U coveralls coverage
pip install -r requirements-${{ matrix.plone }}.txt
- name: Cache eggs
uses: actions/cache@v2
env:
Expand All @@ -108,9 +114,9 @@ jobs:
bin/code-analysis
- name: test coverage
run: |
coverage run bin/test -t !robot
bin/coverage run bin/test -t !robot
- name: Publish to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coveralls --service=github
bin/coveralls --service=github
8 changes: 7 additions & 1 deletion gha.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
[buildout]
extends =
test.cfg
eggs-directory = ~/buildout-cache/eggs
eggs-directory = ~/buildout-cache/eggs

eggs +=
coveralls

[versions]
coveralls = 4.0.1
67 changes: 45 additions & 22 deletions src/collective/documentgenerator/search_replace/pod_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,29 @@ def search(self, find_expr, is_regex=False):
:param is_regex: use is_regex=False if find_expr is not a regex
:return: a dict with podtemplate uid as key and list of SearchReplaceResult as value
"""
grepper = Grep(
keyword=find_expr,
repl=None,
path=self.tmp_dir,
asString=not is_regex,
inContent=False,
dryRun=False,
verbose=0,
vverbose=0,
nice=0
)

if six.PY2:
grepper = Grep(
find_expr,
self.tmp_dir,
repl=None,
asString=not is_regex,
inContent=False,
dryRun=False,
verbose=0,
)
else:
grepper = Grep(
keyword=find_expr,
repl=None,
path=self.tmp_dir,
asString=not is_regex,
inContent=False,
dryRun=False,
verbose=0,
vverbose=0,
nice=0
)
grepper.run()
results = self._prepare_results_output(grepper.matches, is_replacing=False)
return results
Expand All @@ -118,17 +130,28 @@ def replace(self, find_expr, replace_expr, is_regex=False, dry_run=False):
This will not modify the template(s) and can be used safely.
:return: a dict with podtemplate uid as key and list of SearchReplaceResult as value
"""
grepper = Grep(
keyword=find_expr,
path=self.tmp_dir,
repl=replace_expr,
asString=not is_regex,
inContent=False,
dryRun=dry_run,
verbose=0,
vverbose=0,
nice=0
)
if six.PY2:
grepper = Grep(
find_expr,
self.tmp_dir,
repl=replace_expr,
asString=not is_regex,
inContent=False,
dryRun=dry_run,
verbose=0,
)
else:
grepper = Grep(
keyword=find_expr,
path=self.tmp_dir,
repl=replace_expr,
asString=not is_regex,
inContent=False,
dryRun=dry_run,
verbose=0,
vverbose=0,
nice=0
)
grepper.run()
results = self._prepare_results_output(grepper.matches, is_replacing=False)

Expand Down
18 changes: 5 additions & 13 deletions src/collective/documentgenerator/tests/test_DX_helper_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from Products.CMFPlone.utils import safe_unicode
from z3c.form.interfaces import NO_VALUE
from zope.component import getUtility

import datetime
import six

Expand Down Expand Up @@ -67,18 +66,11 @@ def test_DX_proxy_object_behaviour(self):
msg = " __repr__ and __str__ should return the same result as the wrapped object: {} != {}"
self.assertEqual(str(proxy), str(helper_view.real_context), msg.format(str(proxy), str(wrapped)))
msg = u" __unicode__ should return the same result as the wrapped object: {} != {}"
if six.PY2:
self.assertEqual(
safe_unicode(proxy),
safe_unicode(helper_view.real_context),
msg.format(safe_unicode(proxy), safe_unicode(wrapped))
)
else:
self.assertEqual(
str(proxy),
str(helper_view.real_context),
msg.format(str(proxy), str(wrapped))
)
self.assertEqual(
str(proxy),
str(helper_view.real_context),
msg.format(str(proxy), str(wrapped))
)


class TestDexterityHelperViewMethods(DexterityIntegrationTests):
Expand Down
5 changes: 2 additions & 3 deletions src/collective/documentgenerator/tests/test_search_replace.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# coding=utf-8
from collective.documentgenerator.config import HAS_PLONE_6
from collective.documentgenerator.search_replace.pod_template import SearchAndReplacePODTemplates
from collective.documentgenerator.testing import PODTemplateIntegrationTest
from collective.documentgenerator.utils import compute_md5
from imio.helpers import HAS_PLONE_5_AND_MORE
from plone.testing._z2_testbrowser import Browser
from zExceptions import Unauthorized
from zope.interface import Invalid

import io
import os
import six
Expand Down Expand Up @@ -406,7 +405,7 @@ def test_search_replace_control_panel_regex_validator(self):
errors = form.widgets.validate(data)
self.assertEqual(len(errors), 1)
self.assertTrue(isinstance(errors[0], Invalid))
if HAS_PLONE_6:
if HAS_PLONE_5_AND_MORE:
self.assertEqual(errors[0].args[0], u'Incorrect regex at row #2 : "get_elements("')
else:
self.assertEqual(errors[0].message, u'Incorrect regex at row #2 : "get_elements("')
Expand Down
3 changes: 2 additions & 1 deletion test-4.3.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pep517 = 0.12.0
zc.lockfile = 2.0
zope.configuration = 3.8.1
beautifulsoup4 = 4.9.3

soupsieve = 1.9.2
backports.functools-lru-cache = 1.6.4
# plone 4.3 doesn't pin future
future =

Expand Down

0 comments on commit f811693

Please sign in to comment.