Skip to content

Commit

Permalink
Merge branch 'feature/upgrade_testing'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Kaiser committed Nov 18, 2020
2 parents fa2e469 + e07e6e8 commit 87a259a
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 124 deletions.
4 changes: 3 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Change History
2.0.3 - unreleased
------------------

- No changes yet.
- Upgrade to ``pytest>=6``.
- Replace ``pytest-pep8`` with ``pytest-flake8``; fix or silence flake8 warnings/errors
in existing code (mostly tests and migrations).

2.0.2 - 2020-06-22
------------------
Expand Down
8 changes: 6 additions & 2 deletions kotti/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os.path

import pkg_resources
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
Expand Down Expand Up @@ -167,7 +169,6 @@ def get_settings():


def _resolve_dotted(d, keys=conf_dotted):

resolved = d.copy()

for key in keys:
Expand Down Expand Up @@ -281,7 +282,10 @@ def includeme(config):
]:
config.override_asset(to_override="kotti", override_with=override)

config.add_translation_dirs("kotti:locale")
config.add_translation_dirs(f"{os.path.dirname(__file__)}/locale")
# used to be
# config.add_translation_dirs("kotti:locale")
# which fails with recent pytest (works in non testing though)

workflow = settings["kotti.use_workflow"]
if workflow.lower() not in FALSE_VALUES:
Expand Down
2 changes: 1 addition & 1 deletion kotti/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def run_migrations_online():
try:
context.run_migrations()
mark_changed(DBSession())
except:
except: # noqa: E722
traceback.print_exc()
transaction.abort()
else:
Expand Down
2 changes: 1 addition & 1 deletion kotti/alembic/versions/413fa5fcc581_add_filedepot.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def process(thing):
update = files.update().where(files.c.id == bindparam('nodeid')).\
values({files.c.data: bindparam('data')})

def chunks(l, n):
def chunks(l, n): # noqa: E741
for i in range(0, len(l), n):
yield l[i:i + n]

Expand Down
4 changes: 2 additions & 2 deletions kotti/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def _make_script_dir(alembic_cfg: Config) -> ScriptDirectoryWithDefaultEnvPy:

def get_locations() -> List[str]:
conf_str = get_settings()["kotti.alembic_dirs"]
return [l.strip() for l in conf_str.split() if l.strip()]
return [line.strip() for line in conf_str.split() if line.strip()]


def stamp_head(location: str = DEFAULT_LOCATION, revision: None = None) -> None:
Expand Down Expand Up @@ -170,7 +170,7 @@ def upgrade_all():


def list_all():
pkg_envs = [PackageEnvironment(l) for l in get_locations()]
pkg_envs = [PackageEnvironment(location) for location in get_locations()]
for pkg_env in pkg_envs:
print(f"{pkg_env.pkg_name}:")

Expand Down
43 changes: 0 additions & 43 deletions kotti/tests/browser-minimal.txt

This file was deleted.

57 changes: 0 additions & 57 deletions kotti/tests/browser-workflow.txt

This file was deleted.

2 changes: 1 addition & 1 deletion kotti/tests/test_httpexceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_404_anon(webtest, root):


@pytest.mark.user("admin")
def test_404_anon(webtest, root):
def test_404_admin(webtest, root):

resp = webtest.app.get("/non-existent", status=404)
assert "Not Found" in resp.text
Expand Down
2 changes: 1 addition & 1 deletion kotti/views/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def set_cache_headers(event):
# noinspection PyBroadException
try:
caching_policy = caching_policy_chooser(context, request, response)
except:
except: # noqa: E722
# We don't want to screw up the response if the
# caching_policy_chooser raises an exception.
logger.exception(f"{caching_policy_chooser} raised an exception.")
Expand Down
9 changes: 5 additions & 4 deletions kotti/views/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,15 @@ def edit_links(self):
if not hasattr(self.context, "type_info"):
return []
return [
l
for l in self.context.type_info.edit_links
if l.visible(self.context, self.request)
link
for link in self.context.type_info.edit_links
if link.visible(self.context, self.request)
]

@reify
def site_setup_links(self):
return [l for l in CONTROL_PANEL_LINKS if l.visible(self.root, self.request)]
return [link for link in CONTROL_PANEL_LINKS
if link.visible(self.root, self.request)]

@staticmethod
def sanitize(html, sanitizer="default"):
Expand Down
11 changes: 5 additions & 6 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ addopts =
--capture=no
--strict
--tb=native
--travis-fold=auto
--doctest-glob='*.txt'
--doctest-modules
--pep8
--flake8
--cov=kotti
--cov-report=term-missing
kotti/
python_files = test_*.py
pep8ignore = E122 E123 E125 E128 E203 E251 E501 E711 E713 E714 E402 W503
pep8maxlinelength = 88
flake8-ignore =
*.py E122 E123 E125 E128 E203 E251 E501 E711 E713 E714 E402 F821 W503
tests/*.py F841
flake8-max-line-length = 88
markers =
user: mark test to be run as the given user
slow: mark test to be run only with --runslow option
Expand Down
7 changes: 2 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,11 @@
'WebTest',
'mock',
'Pillow', # thumbnail filter in depot tween tests
'py>=1.4.29',
'pyquery',
'pytest>=4.6,<5', # see #563
'pytest>=6',
'pytest-cov',
'pytest-pep8>=1.0.6',
'pytest-travis-fold',
'pytest-flake8',
'pytest-virtualenv',
# 'pytest-xdist', # currently causes Travis to fail
'tox',
'zope.testbrowser>=5.0.0',
]
Expand Down

0 comments on commit 87a259a

Please sign in to comment.