diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml
index fa0d673e..75b51a09 100644
--- a/.github/workflows/python-package.yml
+++ b/.github/workflows/python-package.yml
@@ -11,37 +11,48 @@ on:
jobs:
build:
- runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
- python-version: ["3.9", "3.10"]
-
+ python-version:
+ - "3.8"
+ - "3.9"
+ - "3.10"
+ os:
+ - ubuntu-latest
+ - windows-latest
+ # - macos-latest
+ runs-on: ${{ matrix.os }}
+ env:
+ PYTHONIOENCODING: "utf-8"
+ PYTHONLEGACYWINDOWSSTDIO: "utf-8"
steps:
- - uses: actions/setup-python@v2
- with:
- python-version: '3.10'
- - uses: actions/checkout@v2
- - uses: actions/cache@v2
+ - uses: actions/checkout@v3
+
+ - uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-tox-${{ hashFiles('**/tox.ini') }}-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/constraints.txt') }}-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
+
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v2
+ uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
+ pip install -r requirements.txt
pip install tox-gh-actions>=3.0.0
- pip install -e .
+
- name: Black-Check
run: |
tox -r -e black-check
+
- name: Test with tox
run: |
tox -r
+ env:
+ PLATFORM: ${{ matrix.os }}
diff --git a/.gitignore b/.gitignore
index 833718d5..71428818 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,7 @@ _build
__pycache__
.cache
.vagrant
+/Scripts
# files
local.cfg
pip-selfcheck.json
diff --git a/bobtemplates/plone/addon.py b/bobtemplates/plone/addon.py
index 585ed359..3e906f1d 100644
--- a/bobtemplates/plone/addon.py
+++ b/bobtemplates/plone/addon.py
@@ -46,11 +46,9 @@ def pre_render(configurator):
configurator.variables["package.longname"] = camelcasename.lower()
# jenkins.directories = 'collective/foo/something'
- configurator.variables["jenkins.directories"] = configurator.variables[
- "package.distributionname"
- ].replace(
- ".", "/"
- ) # NOQA: E501
+ configurator.variables["jenkins.directories"] = os.path.join(
+ *configurator.variables["package.distributionname"].split(".")
+ )
if namespaces:
configurator.variables["package.namespace_packages"] = ", ".join(
diff --git a/bobtemplates/plone/addon/tox.ini b/bobtemplates/plone/addon/tox.ini
index 6a7e0ec4..29004f38 100644
--- a/bobtemplates/plone/addon/tox.ini
+++ b/bobtemplates/plone/addon/tox.ini
@@ -5,29 +5,25 @@ envlist =
py39-lint,
py310-lint,
black-check,
- py{38,37}-Plone{52},
+ py{37,38}-Plone{52},
py{39,310}-Plone{60},
# docs,
# coverage-report,
skip_missing_interpreters = True
-
[gh-actions]
python =
- 3.6: py36
3.7: py37
3.8: py38
3.9: py39
3.10: py310
-
[gh-actions:env]
PLONE-VERSION =
Plone52: Plone52
Plone60: Plone60
-
[testenv]
skip_install = true
@@ -36,11 +32,11 @@ extras =
test
commands =
- {envbindir}/buildout -q -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} bootstrap
-# {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} annotate
- {envbindir}/buildout -n -qq -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} install test robot
- coverage run {envbindir}/test -v1 --auto-color {posargs}
- # coverage run {envbindir}/test -v --all -t robot {posargs}
+ {envbindir}{/}buildout -q -c {toxinidir}{/}{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} bootstrap
+# {envbindir}{/}buildout -c {toxinidir}{/}{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} annotate
+ {envbindir}{/}buildout -n -qq -c {toxinidir}{/}{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} install test robot
+ coverage run {envbindir}{/}test -v1 --auto-color {posargs}
+ # coverage run {envbindir}{/}test -v --all -t robot {posargs}
setenv =
COVERAGE_FILE=.coverage.{envname}
@@ -106,10 +102,10 @@ deps =
#flake8-polyfill
commands =
- mkdir -p {toxinidir}/reports/flake8
- flake8 --doctests {toxinidir}/src {toxinidir}/setup.py
- isort --check-only {toxinidir}/src {toxinidir}/setup.py
- # black --check --diff -v {toxinidir}/src {toxinidir}/setup.py
+ mkdir -p {toxinidir}{/}reports{/}flake8
+ flake8 --doctests {toxinidir}{/}src {toxinidir}{/}setup.py
+ isort --check-only {toxinidir}{/}src {toxinidir}{/}setup.py
+ # black --check --diff -v {toxinidir}{/}src {toxinidir}{/}setup.py
allowlist_externals =
mkdir
@@ -123,8 +119,7 @@ deps =
isort
commands =
- isort {toxinidir}/src {toxinidir}/setup.py
-
+ isort {toxinidir}{/}src {toxinidir}{/}setup.py
[testenv:black-check]
basepython = python3.9
@@ -183,4 +178,4 @@ deps =
Sphinx
commands =
- sphinx-build -b html -d _build/docs/doctrees docs _build/docs/html
+ sphinx-build -b html -d _build{/}docs{/}doctrees docs _build{/}docs/html
diff --git a/bobtemplates/plone/base.py b/bobtemplates/plone/base.py
index d3afd119..c5938f1f 100644
--- a/bobtemplates/plone/base.py
+++ b/bobtemplates/plone/base.py
@@ -206,7 +206,7 @@ def check_method_name(configurator, question, answer):
def read_bobtemplates_ini(configurator):
bob_config = BobConfig()
config = ConfigParser()
- path = configurator.target_directory + "/bobtemplate.cfg"
+ path = os.path.join(configurator.target_directory, "bobtemplate.cfg")
config.read(path)
if not config.sections():
return
@@ -337,12 +337,10 @@ def update_configure_zcml(
match_str=None,
insert_str=None,
):
- if path[-1] != "/":
- path += "/"
file_path = os.path.join(path, file_name)
if example_file_name:
example_file_path = os.path.join(path, example_file_name)
- file_list = os.listdir(os.path.dirname(path))
+ file_list = os.listdir(path)
if file_name not in file_list:
print("rename example zcml file")
os.rename(example_file_path, file_path)
@@ -421,7 +419,7 @@ def check_root_folder(configurator, question):
def dottedname_to_path(dottedname):
- path = "/".join(dottedname.split("."))
+ path = os.path.join(*dottedname.split("."))
return path
@@ -447,10 +445,12 @@ def base_prepare_renderer(configurator):
)
package_subpath = dottedname_to_path(configurator.variables["package.dottedname"])
- configurator.variables["package_folder_rel_path"] = "/src/" + package_subpath
- configurator.variables["package_folder"] = (
- configurator.variables["package.root_folder"]
- + configurator.variables["package_folder_rel_path"]
+ configurator.variables["package_folder_rel_path"] = os.path.join(
+ "", "src", package_subpath
+ )
+ configurator.variables["package_folder"] = os.path.join(
+ configurator.variables["package.root_folder"],
+ configurator.variables["package_folder_rel_path"],
)
configurator.target_directory = configurator.variables["package.root_folder"]
camelcasename = (
diff --git a/bobtemplates/plone/behavior.py b/bobtemplates/plone/behavior.py
index e29dd167..187f332d 100644
--- a/bobtemplates/plone/behavior.py
+++ b/bobtemplates/plone/behavior.py
@@ -13,7 +13,7 @@
def _update_package_configure_zcml(configurator):
file_name = "configure.zcml"
- file_path = configurator.variables["package_folder"] + "/" + file_name
+ file_path = os.path.join(configurator.variables["package_folder"], file_name)
nsprefix = "{http://namespaces.zope.org/zope}"
with open(file_path, "r") as xml_file:
@@ -39,7 +39,9 @@ def _update_package_configure_zcml(configurator):
def _update_behaviors_configure_zcml(configurator):
file_name = "configure.zcml"
- file_path = configurator.variables["package_folder"] + "/behaviors/" + file_name
+ file_path = os.path.join(
+ configurator.variables["package_folder"], "behaviors", file_name
+ )
example_file_path = file_path + ".example"
file_list = os.listdir(os.path.dirname(file_path))
if file_name not in file_list:
diff --git a/bobtemplates/plone/content_type.py b/bobtemplates/plone/content_type.py
index f6b84ae1..0f3f3cbe 100644
--- a/bobtemplates/plone/content_type.py
+++ b/bobtemplates/plone/content_type.py
@@ -60,13 +60,11 @@ def check_global_allow(configurator, answer):
def _update_metadata_xml(configurator):
"""Add plone.app.dexterity dependency metadata.xml in Generic Setup profiles.""" # NOQA: E501
metadata_file_name = "metadata.xml"
- metadata_file_dir = "profiles/default"
- metadata_file_path = (
- configurator.variables["package_folder"]
- + "/"
- + metadata_file_dir
- + "/"
- + metadata_file_name
+ metadata_file_path = os.path.join(
+ configurator.variables["package_folder"],
+ "profiles",
+ "default",
+ metadata_file_name,
)
with open(metadata_file_path, "r") as xml_file:
@@ -111,11 +109,11 @@ def _update_types_xml(configurator):
"""Add the new type to types.xml in Generic Setup profiles."""
types_file_name = "types.xml"
types_file_dir = "profiles/default"
- types_file_path = (
- configurator.target_directory + "/" + types_file_dir + "/" + types_file_name
+ types_file_path = os.path.join(
+ configurator.target_directory, types_file_dir, types_file_name
)
- types_example_file_path = (
- configurator.target_directory + "/" + types_file_dir + "/types.xml.example"
+ types_example_file_path = os.path.join(
+ configurator.target_directory, types_file_dir, "types.xml.example"
)
file_list = os.listdir(os.path.dirname(types_file_path))
if types_file_name not in file_list:
@@ -156,8 +154,11 @@ def _update_parent_types_fti_xml(configurator):
file_name = "{0}.xml".format(
parent_dexterity_type_fti_file_name,
)
- file_path = "{0}/profiles/default/types/{1}".format(
+ file_path = os.path.join(
configurator.variables["package_folder"],
+ "profiles",
+ "default",
+ "types",
file_name,
)
@@ -186,8 +187,10 @@ def _update_parent_types_fti_xml(configurator):
def _update_rolemap_xml(configurator):
file_name = "rolemap.xml"
- file_path = "{0}/profiles/default/{1}".format(
+ file_path = os.path.join(
configurator.variables["package_folder"],
+ "profiles",
+ "default",
file_name,
)
@@ -224,7 +227,7 @@ def _update_rolemap_xml(configurator):
def _update_permissions_zcml(configurator):
file_name = "permissions.zcml"
- file_path = configurator.variables["package_folder"] + "/" + file_name
+ file_path = os.path.join(configurator.variables["package_folder"], file_name)
nsprefix = "{http://namespaces.zope.org/zope}"
with open(file_path, "r") as xml_file:
diff --git a/bobtemplates/plone/controlpanel.py b/bobtemplates/plone/controlpanel.py
index 54e29ad9..de9009d4 100644
--- a/bobtemplates/plone/controlpanel.py
+++ b/bobtemplates/plone/controlpanel.py
@@ -14,7 +14,7 @@
def _update_package_configure_zcml(configurator):
file_name = "configure.zcml"
- file_path = configurator.variables["package_folder"] + "/" + file_name
+ file_path = os.path.join(configurator.variables["package_folder"], file_name)
with open(file_path, "r") as xml_file:
parser = etree.XMLParser(remove_blank_text=True)
@@ -35,10 +35,14 @@ def _update_package_configure_zcml(configurator):
def _update_controlpanels_configure_zcml(configurator):
+ directory_path = os.path.join(
+ configurator.variables["package_folder"],
+ "controlpanels",
+ )
file_name = "configure.zcml"
- file_path = configurator.variables["package_folder"] + "/controlpanels/" + file_name
+ file_path = os.path.join(directory_path, file_name)
example_file_path = file_path + ".example"
- file_list = os.listdir(os.path.dirname(file_path))
+ file_list = os.listdir(directory_path)
if file_name not in file_list:
os.rename(example_file_path, file_path)
@@ -72,8 +76,11 @@ def _update_controlpanels_configure_zcml(configurator):
def _update_profile_controlpanel_xml(configurator):
file_name = "controlpanel.xml"
- file_path = (
- configurator.variables["package_folder"] + "/profiles/default/" + file_name
+ file_path = os.path.join(
+ configurator.variables["package_folder"],
+ "profiles",
+ "default",
+ file_name,
)
example_file_path = file_path + ".example"
file_list = os.listdir(os.path.dirname(file_path))
diff --git a/bobtemplates/plone/form.py b/bobtemplates/plone/form.py
index f1bec896..71206c35 100644
--- a/bobtemplates/plone/form.py
+++ b/bobtemplates/plone/form.py
@@ -48,12 +48,10 @@ def get_form_configuration(configurator):
def _update_forms_configure_zcml(configurator):
file_name = "configure.zcml"
- directory_path = configurator.variables["package_folder"] + "/forms/"
- file_path = directory_path + file_name
- configure_example_file_path = (
- configurator.variables["package_folder"] + "/forms/configure.zcml.example"
- )
- file_list = os.listdir(os.path.dirname(directory_path))
+ directory_path = os.path.join(configurator.variables["package_folder"], "forms")
+ file_path = os.path.join(directory_path, file_name)
+ configure_example_file_path = os.path.join(directory_path, "configure.zcml.example")
+ file_list = os.listdir(directory_path)
if file_name not in file_list:
os.rename(configure_example_file_path, file_path)
@@ -107,7 +105,7 @@ def _update_forms_configure_zcml(configurator):
def _update_configure_zcml(configurator):
file_name = "configure.zcml"
- file_path = configurator.variables["package_folder"] + "/" + file_name
+ file_path = os.path.join(configurator.variables["package_folder"], file_name)
namespaces = "{http://namespaces.zope.org/zope}"
with open(file_path, "r") as xml_file:
@@ -129,12 +127,11 @@ def _update_configure_zcml(configurator):
def _delete_unwanted_files(configurator):
- directory_path = configurator.variables["package_folder"] + "/forms/"
-
+ directory_path = os.path.join(configurator.variables["package_folder"], "forms")
file_name = "configure.zcml.example"
- file_list = os.listdir(os.path.dirname(directory_path))
+ file_list = os.listdir(directory_path)
if file_name in file_list:
- file_path = directory_path + file_name
+ file_path = os.path.join(directory_path, file_name)
os.remove(file_path)
diff --git a/bobtemplates/plone/indexer.py b/bobtemplates/plone/indexer.py
index 493303c4..09de7df4 100644
--- a/bobtemplates/plone/indexer.py
+++ b/bobtemplates/plone/indexer.py
@@ -8,6 +8,7 @@
from bobtemplates.plone.utils import run_isort
import case_conversion as cc
+import os
def _update_package_configure_zcml(configurator):
@@ -31,8 +32,9 @@ def _update_package_configure_zcml(configurator):
def _update_indexers_configure_zcml(configurator):
- path = "{0}/indexers".format(
+ path = os.path.join(
configurator.variables["package_folder"],
+ "indexers",
)
file_name = "configure.zcml"
example_file_name = "{0}.example".format(file_name)
@@ -59,11 +61,11 @@ def _update_indexers_configure_zcml(configurator):
def _remove_unwanted_files(configurator):
file_paths = []
rel_file_paths = [
- "/indexers/configure.zcml.example",
+ os.path.join("indexers", "configure.zcml.example"),
]
base_path = configurator.variables["package_folder"]
for rel_file_path in rel_file_paths:
- file_paths.append("{0}{1}".format(base_path, rel_file_path))
+ file_paths.append(os.path.join(base_path, rel_file_path))
remove_unwanted_files(file_paths)
diff --git a/bobtemplates/plone/mockup_pattern.py b/bobtemplates/plone/mockup_pattern.py
index 91c955a7..6ad5b165 100644
--- a/bobtemplates/plone/mockup_pattern.py
+++ b/bobtemplates/plone/mockup_pattern.py
@@ -15,7 +15,7 @@ def pre_render(configurator):
configurator.variables["template_id"] = "mockup_pattern"
bundle_js_path = os.path.join(
- configurator.variables["package.root_folder"], "resources/bundle.js"
+ configurator.variables["package.root_folder"], "resources", "bundle.js"
)
configurator.variables["original_imports"] = ""
if os.path.exists(bundle_js_path):
diff --git a/bobtemplates/plone/portlet.py b/bobtemplates/plone/portlet.py
index 36626186..b3c1ef20 100644
--- a/bobtemplates/plone/portlet.py
+++ b/bobtemplates/plone/portlet.py
@@ -19,12 +19,14 @@
def _update_portlets_configure_zcml(configurator):
file_name = "configure.zcml"
- directory_path = configurator.variables["package_folder"] + "/portlets/"
- file_path = directory_path + file_name
- configure_example_file_path = (
- configurator.variables["package_folder"] + "/portlets/configure.zcml.example"
+ directory_path = os.path.join(configurator.variables["package_folder"], "portlets")
+ file_path = os.path.join(directory_path, file_name)
+ configure_example_file_path = os.path.join(
+ configurator.variables["package_folder"],
+ "portlets",
+ "configure.zcml.example",
) # NOQA: E501
- file_list = os.listdir(os.path.dirname(directory_path))
+ file_list = os.listdir(directory_path)
if file_name not in file_list:
os.rename(configure_example_file_path, file_path)
@@ -70,15 +72,17 @@ def _update_portlets_configure_zcml(configurator):
def _update_portlets_xml(configurator):
file_name = "portlets.xml"
- directory_path = (
- configurator.variables["package_folder"] + "/profiles/default/"
- ) # NOQA: E501
- file_path = directory_path + file_name
- configure_example_file_path = (
- configurator.variables["package_folder"]
- + "/profiles/default/portlets.xml.example"
- ) # NOQA: E501
- file_list = os.listdir(os.path.dirname(directory_path))
+ directory_path = os.path.join(
+ configurator.variables["package_folder"],
+ "profiles",
+ "default",
+ )
+ file_path = os.path.join(directory_path, file_name)
+ configure_example_file_path = os.path.join(
+ directory_path,
+ "portlets.xml.example",
+ )
+ file_list = os.listdir(directory_path)
if file_name not in file_list:
os.rename(configure_example_file_path, file_path)
@@ -132,23 +136,23 @@ def _update_portlets_xml(configurator):
def _delete_unnecessary_files(configurator):
directory_path = configurator.variables["package_folder"]
- configure_path = directory_path + "/portlets/"
+ configure_path = os.path.join(directory_path, "portlets")
file_name = "configure.zcml.example"
- file_list = os.listdir(os.path.dirname(configure_path))
+ file_list = os.listdir(configure_path)
if file_name in file_list:
- file_path = configure_path + file_name
+ file_path = os.path.join(configure_path, file_name)
os.remove(file_path)
- portlets_xml_path = directory_path + "/profiles/default/"
+ portlets_xml_path = os.path.join(directory_path, "profiles", "default")
file_name = "portlets.xml.example"
- file_list = os.listdir(os.path.dirname(portlets_xml_path))
+ file_list = os.listdir(portlets_xml_path)
if file_name in file_list:
- file_path = portlets_xml_path + file_name
+ file_path = os.path.join(portlets_xml_path, file_name)
os.remove(file_path)
def _update_configure_zcml(configurator):
file_name = "configure.zcml"
- file_path = configurator.variables["package_folder"] + "/" + file_name
+ file_path = os.path.join(configurator.variables["package_folder"], file_name)
with open(file_path, "r") as xml_file:
parser = etree.XMLParser(remove_blank_text=True)
diff --git a/bobtemplates/plone/restapi_service.py b/bobtemplates/plone/restapi_service.py
index ff7cfc61..0bad7db2 100644
--- a/bobtemplates/plone/restapi_service.py
+++ b/bobtemplates/plone/restapi_service.py
@@ -9,6 +9,7 @@
from lxml import etree
import case_conversion as cc
+import os
def get_service_name_from_python_class(configurator, question):
@@ -42,8 +43,9 @@ def _update_package_configure_zcml(configurator):
def _update_api_configure_zcml(configurator):
- path = "{0}/api".format(
+ path = os.path.join(
configurator.variables["package_folder"],
+ "api",
)
file_name = "configure.zcml"
example_file_name = "{0}.example".format(file_name)
@@ -64,8 +66,10 @@ def _update_api_configure_zcml(configurator):
def _update_services_configure_zcml(configurator):
- path = "{0}/api/services".format(
+ path = os.path.join(
configurator.variables["package_folder"],
+ "api",
+ "services",
)
file_name = "configure.zcml"
example_file_name = "{0}.example".format(file_name)
@@ -93,12 +97,10 @@ def _update_metadata_xml(configurator):
"""
metadata_file_name = "metadata.xml"
metadata_file_dir = "profiles/default"
- metadata_file_path = (
- configurator.variables["package_folder"]
- + "/"
- + metadata_file_dir
- + "/"
- + metadata_file_name
+ metadata_file_path = os.path.join(
+ configurator.variables["package_folder"],
+ metadata_file_dir,
+ metadata_file_name,
)
with open(metadata_file_path, "r") as xml_file:
diff --git a/bobtemplates/plone/svelte_app.py b/bobtemplates/plone/svelte_app.py
index 9b72c742..b969930a 100644
--- a/bobtemplates/plone/svelte_app.py
+++ b/bobtemplates/plone/svelte_app.py
@@ -10,6 +10,7 @@
from mrbob.bobexceptions import ValidationError
import case_conversion as cc
+import os
import re
@@ -25,7 +26,7 @@ def check_name(configurator, question, answer):
def _update_configure_zcml(configurator):
file_name = "configure.zcml"
- file_path = configurator.variables["package_folder"] + "/" + file_name
+ file_path = os.path.join(configurator.variables["package_folder"], file_name)
namespaces = {"plone": "http://namespaces.plone.org/plone"}
with open(file_path, "r") as xml_file:
diff --git a/bobtemplates/plone/theme.py b/bobtemplates/plone/theme.py
index 018a14ab..abd6d768 100644
--- a/bobtemplates/plone/theme.py
+++ b/bobtemplates/plone/theme.py
@@ -57,12 +57,10 @@ def _update_metadata_xml(configurator):
profiles."""
metadata_file_name = "metadata.xml"
metadata_file_dir = "profiles/default"
- metadata_file_path = (
- configurator.variables["package_folder"]
- + "/"
- + metadata_file_dir
- + "/"
- + metadata_file_name
+ metadata_file_path = os.path.join(
+ configurator.variables["package_folder"],
+ metadata_file_dir,
+ metadata_file_name,
)
with open(metadata_file_path, "r") as xml_file:
@@ -98,7 +96,7 @@ def _update_metadata_xml(configurator):
def _update_configure_zcml(configurator):
file_name = "configure.zcml"
- file_path = configurator.variables["package_folder"] + "/" + file_name
+ file_path = os.path.join(configurator.variables["package_folder"], file_name)
with open(file_path, "r") as xml_file:
parser = etree.XMLParser(remove_blank_text=True)
@@ -130,7 +128,7 @@ def _update_configure_zcml(configurator):
def _update_setup_py(configurator):
file_name = "setup.py"
- file_path = configurator.variables["package.root_folder"] + "/" + file_name
+ file_path = os.path.join(configurator.variables["package.root_folder"], file_name)
match_str = "-*- Extra requirements: -*-"
insert_strings = [
# "plone.app.themingplugins",
diff --git a/bobtemplates/plone/theme_barceloneta.py b/bobtemplates/plone/theme_barceloneta.py
index e6d18f29..03fca4a4 100644
--- a/bobtemplates/plone/theme_barceloneta.py
+++ b/bobtemplates/plone/theme_barceloneta.py
@@ -56,12 +56,10 @@ def _update_metadata_xml(configurator):
profiles."""
metadata_file_name = "metadata.xml"
metadata_file_dir = "profiles/default"
- metadata_file_path = (
- configurator.variables["package_folder"]
- + "/"
- + metadata_file_dir
- + "/"
- + metadata_file_name
+ metadata_file_path = os.path.join(
+ configurator.variables["package_folder"],
+ metadata_file_dir,
+ metadata_file_name,
)
with open(metadata_file_path, "r") as xml_file:
@@ -88,7 +86,7 @@ def _update_metadata_xml(configurator):
def _update_configure_zcml(configurator):
file_name = "configure.zcml"
- file_path = configurator.variables["package_folder"] + "/" + file_name
+ file_path = os.path.join(configurator.variables["package_folder"], file_name)
namespaces = {"plone": "http://namespaces.plone.org/plone"}
with open(file_path, "r") as xml_file:
@@ -119,7 +117,7 @@ def _update_configure_zcml(configurator):
# def _update_setup_py(configurator):
# file_name = u"setup.py"
-# file_path = configurator.variables["package.root_folder"] + "/" + file_name
+# file_path = os.path.join(configurator.variables["package.root_folder"], file_name)
# match_str = "-*- Extra requirements: -*-"
# insert_strings = [
# # "collective.themesitesetup", # disable while not ready for Plone 5.2
diff --git a/bobtemplates/plone/theme_basic.py b/bobtemplates/plone/theme_basic.py
index 8905a827..f2f973ee 100644
--- a/bobtemplates/plone/theme_basic.py
+++ b/bobtemplates/plone/theme_basic.py
@@ -56,12 +56,10 @@ def _update_metadata_xml(configurator):
profiles."""
metadata_file_name = "metadata.xml"
metadata_file_dir = "profiles/default"
- metadata_file_path = (
- configurator.variables["package_folder"]
- + "/"
- + metadata_file_dir
- + "/"
- + metadata_file_name
+ metadata_file_path = os.path.join(
+ configurator.variables["package_folder"],
+ metadata_file_dir,
+ metadata_file_name,
)
with open(metadata_file_path, "r") as xml_file:
@@ -88,7 +86,7 @@ def _update_metadata_xml(configurator):
def _update_configure_zcml(configurator):
file_name = "configure.zcml"
- file_path = configurator.variables["package_folder"] + "/" + file_name
+ file_path = os.path.join(configurator.variables["package_folder"], file_name)
namespaces = {"plone": "http://namespaces.plone.org/plone"}
with open(file_path, "r") as xml_file:
diff --git a/bobtemplates/plone/upgrade_step.py b/bobtemplates/plone/upgrade_step.py
index 8373282d..2efb18d9 100644
--- a/bobtemplates/plone/upgrade_step.py
+++ b/bobtemplates/plone/upgrade_step.py
@@ -6,6 +6,8 @@
from bobtemplates.plone.base import update_configure_zcml
from lxml import etree
+import os
+
def _update_package_configure_zcml(configurator):
path = "{0}".format(
@@ -83,12 +85,10 @@ def _write_dest_version(configurator):
"""Add plone.app.dexterity dependency metadata.xml in Generic Setup profiles.""" # NOQA: E501
metadata_file_name = "metadata.xml"
metadata_file_dir = "profiles/default"
- metadata_file_path = (
- configurator.variables["package_folder"]
- + "/"
- + metadata_file_dir
- + "/"
- + metadata_file_name
+ metadata_file_path = os.path.join(
+ configurator.variables["package_folder"],
+ metadata_file_dir,
+ metadata_file_name,
)
with open(metadata_file_path, "r") as xml_file:
diff --git a/bobtemplates/plone/view.py b/bobtemplates/plone/view.py
index 6d418a5e..81d5390f 100644
--- a/bobtemplates/plone/view.py
+++ b/bobtemplates/plone/view.py
@@ -87,12 +87,14 @@ def get_view_configuration(configurator):
def _update_views_configure_zcml(configurator):
file_name = "configure.zcml"
- directory_path = configurator.variables["package_folder"] + "/views/"
- file_path = directory_path + file_name
- configure_example_file_path = (
- configurator.variables["package_folder"] + "/views/configure.zcml.example"
+ directory_path = os.path.join(configurator.variables["package_folder"], "views")
+ file_path = os.path.join(directory_path, file_name)
+ configure_example_file_path = os.path.join(
+ configurator.variables["package_folder"],
+ "views",
+ "configure.zcml.example",
)
- file_list = os.listdir(os.path.dirname(directory_path))
+ file_list = os.listdir(directory_path)
if file_name not in file_list:
os.rename(configure_example_file_path, file_path)
@@ -146,7 +148,7 @@ def _update_views_configure_zcml(configurator):
def _update_configure_zcml(configurator):
file_name = "configure.zcml"
- file_path = configurator.variables["package_folder"] + "/" + file_name
+ file_path = os.path.join(configurator.variables["package_folder"], file_name)
namespaces = "{http://namespaces.zope.org/zope}"
with open(file_path, "r") as xml_file:
@@ -168,25 +170,25 @@ def _update_configure_zcml(configurator):
def _delete_unwanted_files(configurator):
- directory_path = configurator.variables["package_folder"] + "/views/"
+ directory_path = os.path.join(configurator.variables["package_folder"], "views")
if not configurator.variables["view_template"]:
file_name = "{0}.pt".format(
configurator.variables["view_template_name"],
)
- file_path = directory_path + file_name
+ file_path = os.path.join(directory_path, file_name)
os.remove(file_path)
elif not configurator.variables["view_python_class"]:
file_name = "{0}.py".format(
configurator.variables["view_python_file_name"],
)
- file_path = directory_path + file_name
+ file_path = os.path.join(directory_path, file_name)
os.remove(file_path)
file_name = "configure.zcml.example"
- file_list = os.listdir(os.path.dirname(directory_path))
+ file_list = os.listdir(directory_path)
if file_name in file_list:
- file_path = directory_path + file_name
+ file_path = os.path.join(directory_path, file_name)
os.remove(file_path)
diff --git a/bobtemplates/plone/viewlet.py b/bobtemplates/plone/viewlet.py
index c10c8f85..34091496 100644
--- a/bobtemplates/plone/viewlet.py
+++ b/bobtemplates/plone/viewlet.py
@@ -30,7 +30,7 @@ def check_viewlet_template_answer(configurator, question):
def _update_configure_zcml(configurator):
file_name = "configure.zcml"
- file_path = configurator.variables["package_folder"] + "/" + file_name
+ file_path = os.path.join(configurator.variables["package_folder"], file_name)
namespaces = "{http://namespaces.zope.org/zope}"
with open(file_path, "r") as xml_file:
@@ -53,13 +53,11 @@ def _update_configure_zcml(configurator):
def _update_viewlets_configure_zcml(configurator):
file_name = "configure.zcml"
- directory_path = configurator.variables["package_folder"] + "/viewlets/"
- file_path = directory_path + file_name
+ directory_path = os.path.join(configurator.variables["package_folder"], "viewlets")
+ file_path = os.path.join(directory_path, file_name)
- configure_example_file_path = (
- configurator.variables["package_folder"] + "/viewlets/configure.zcml.example"
- ) # NOQA: E501
- file_list = os.listdir(os.path.dirname(directory_path))
+ configure_example_file_path = os.path.join(directory_path, "configure.zcml.example")
+ file_list = os.listdir(directory_path)
if file_name not in file_list:
os.rename(configure_example_file_path, file_path)
@@ -126,18 +124,18 @@ def _update_viewlets_configure_zcml(configurator):
def _delete_unwanted_files(configurator):
- directory_path = configurator.variables["package_folder"] + "/viewlets/"
+ directory_path = os.path.join(configurator.variables["package_folder"], "viewlets")
if not configurator.variables["viewlet_template"]:
template_file_name = "{0}.pt".format(
configurator.variables["viewlet_template_name"],
)
- file_path = directory_path + template_file_name
+ file_path = os.path.join(directory_path, template_file_name)
os.remove(file_path)
file_name = "configure.zcml.example"
- file_list = os.listdir(os.path.dirname(directory_path))
+ file_list = os.listdir(directory_path)
if file_name in file_list:
- file_path = directory_path + file_name
+ file_path = os.path.join(directory_path, file_name)
os.remove(file_path)
diff --git a/bobtemplates/plone/vocabulary.py b/bobtemplates/plone/vocabulary.py
index b2b17640..1c1168f4 100644
--- a/bobtemplates/plone/vocabulary.py
+++ b/bobtemplates/plone/vocabulary.py
@@ -15,7 +15,7 @@
def _update_package_configure_zcml(configurator):
file_name = "configure.zcml"
- file_path = configurator.variables["package_folder"] + "/" + file_name
+ file_path = os.path.join(configurator.variables["package_folder"], file_name)
with open(file_path, "r") as xml_file:
parser = etree.XMLParser(remove_blank_text=True)
@@ -36,10 +36,14 @@ def _update_package_configure_zcml(configurator):
def _update_vocabularies_configure_zcml(configurator):
+ directory_path = os.path.join(
+ configurator.variables["package_folder"],
+ "vocabularies",
+ )
file_name = "configure.zcml"
- file_path = configurator.variables["package_folder"] + "/vocabularies/" + file_name
+ file_path = os.path.join(directory_path, file_name)
example_file_path = file_path + ".example"
- file_list = os.listdir(os.path.dirname(file_path))
+ file_list = os.listdir(directory_path)
if file_name not in file_list:
os.rename(example_file_path, file_path)
diff --git a/constraints.txt b/constraints.txt
index d7bffc21..6c2945ce 100644
--- a/constraints.txt
+++ b/constraints.txt
@@ -2,7 +2,8 @@
# -----------------------------------------------
# Pin Versions / Version Ranges if necessary.
setuptools==57.0.0
-tox==4.3.5
+wheel==0.38.4
+tox==4.4.4
isort>=5
flake8==5.0.4
flake8-html==0.4.2
diff --git a/package_tests/base.py b/package_tests/base.py
index c9158938..d900d148 100644
--- a/package_tests/base.py
+++ b/package_tests/base.py
@@ -8,11 +8,10 @@ def init_package_base_structure(package_root):
expects: package_root
returns: package_path
"""
- package_name = package_root.split("/")[-1]
+ package_name = os.path.split(package_root)[-1]
namespace_parts = package_name.split(".")
- package_namespace_path = "/".join(namespace_parts)
- package_path = os.path.join(package_root, "src/" + package_namespace_path)
- profiles_path = os.path.join(package_path, "profiles/default")
+ package_path = os.path.join(package_root, "src", *namespace_parts)
+ profiles_path = os.path.join(package_path, "profiles", "default")
svelte_apps_path = os.path.join(package_path, "svelte_apps")
theme_path = os.path.join(package_path, "theme")
os.makedirs(package_root)
@@ -24,14 +23,14 @@ def init_package_base_structure(package_root):
[main]
version=5.1
"""
- with open(os.path.join(package_root + "/bobtemplate.cfg"), "w") as f:
+ with open(os.path.join(package_root, "bobtemplate.cfg"), "w") as f:
f.write(template)
template = """
dummy
'-*- Extra requirements: -*-'
"""
- with open(os.path.join(package_root + "/setup.py"), "w") as f:
+ with open(os.path.join(package_root, "setup.py"), "w") as f:
f.write(template)
template = """
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
template = """
@@ -64,7 +63,7 @@ def init_package_base_structure(package_root):
"""
- with open(os.path.join(profiles_path + "/metadata.xml"), "w") as f:
+ with open(os.path.join(profiles_path, "metadata.xml"), "w") as f:
f.write(template)
return package_path
diff --git a/package_tests/test_addon.py b/package_tests/test_addon.py
index 8c7348e3..1e6c2134 100644
--- a/package_tests/test_addon.py
+++ b/package_tests/test_addon.py
@@ -10,7 +10,7 @@
def test_pre_render(tmpdir):
configurator = Configurator(
template="bobtemplates.plone:addon",
- target_directory=tmpdir.strpath + "collective.foo.bar",
+ target_directory=os.path.join(tmpdir.strpath, "collective.foo.bar"),
variables={
"package.dexterity_type_name": "Task",
},
@@ -19,9 +19,9 @@ def test_pre_render(tmpdir):
def test_cleanup_package(tmpdir):
- target_path = tmpdir.strpath + "/collective.foo.bar"
- package_path = target_path + "/src/collective/foo/bar"
- profiles_path = package_path + "/profiles/default"
+ target_path = os.path.join(tmpdir.strpath, "collective.foo.bar")
+ package_path = os.path.join(target_path, "src", "collective", "foo", "bar")
+ profiles_path = os.path.join(package_path, "profiles", "default")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(profiles_path)
@@ -33,7 +33,7 @@ def test_cleanup_package(tmpdir):
"""
- with open(os.path.join(profiles_path + "/metadata.xml"), "w") as f:
+ with open(os.path.join(profiles_path, "metadata.xml"), "w") as f:
f.write(template)
configurator = Configurator(
@@ -67,11 +67,11 @@ def test_cleanup_package(tmpdir):
def test_no_namespace(tmpdir):
configurator = Configurator(
template="bobtemplates.plone:addon",
- target_directory=tmpdir.strpath + "mypackage",
+ target_directory=os.path.join(tmpdir.strpath, "mypackage"),
variables={},
)
addon.pre_render(configurator)
- name = os.path.split(tmpdir.strpath + "mypackage")[-1]
+ name = "mypackage"
assert configurator.variables["package.dottedname"] == name
assert configurator.variables["package.distributionname"] == name
@@ -80,23 +80,23 @@ def test_with_dash(tmpdir):
# no namespace
configurator = Configurator(
template="bobtemplates.plone:addon",
- target_directory=tmpdir.strpath + "my-package",
+ target_directory=os.path.join(tmpdir.strpath, "my-package"),
variables={},
)
addon.pre_render(configurator)
- package_name = os.path.split(tmpdir.strpath + "my_package")[-1]
- distribution_name = os.path.split(tmpdir.strpath + "my-package")[-1]
+ package_name = "my_package"
+ distribution_name = "my-package"
assert configurator.variables["package.dottedname"] == package_name
assert configurator.variables["package.distributionname"] == distribution_name
# with namespace
configurator = Configurator(
template="bobtemplates.plone:addon",
- target_directory=tmpdir.strpath + "my-namespace.my-package",
+ target_directory=os.path.join(tmpdir.strpath, "my-namespace.my-package"),
variables={},
)
addon.pre_render(configurator)
- package_name = os.path.split(tmpdir.strpath + "my_namespace.my_package")[-1]
- distribution_name = os.path.split(tmpdir.strpath + "my-namespace.my-package")[-1]
+ package_name = "my_namespace.my_package"
+ distribution_name = "my-namespace.my-package"
assert configurator.variables["package.dottedname"] == package_name
assert configurator.variables["package.distributionname"] == distribution_name
diff --git a/package_tests/test_base.py b/package_tests/test_base.py
index c78af54e..00d96acb 100644
--- a/package_tests/test_base.py
+++ b/package_tests/test_base.py
@@ -5,6 +5,7 @@
import os
import pytest
+import sys
def test_to_boolean():
@@ -45,9 +46,9 @@ def test_read_bobtemplate_ini(tmpdir):
template = """[main]
version=5.1
"""
- target_dir = tmpdir.strpath + "/collective.foo"
+ target_dir = os.path.join(tmpdir.strpath, "collective.foo")
os.mkdir(target_dir)
- with open(os.path.join(target_dir + "/bobtemplate.cfg"), "w") as f:
+ with open(os.path.join(target_dir, "bobtemplate.cfg"), "w") as f:
f.write(template)
configurator = Configurator(
@@ -61,9 +62,9 @@ def test_set_global_vars(tmpdir):
[main]
version=5.1
"""
- target_dir = tmpdir.strpath + "/collective.foo"
+ target_dir = os.path.join(tmpdir.strpath, "collective.foo")
os.mkdir(target_dir)
- with open(os.path.join(target_dir + "/bobtemplate.cfg"), "w") as f:
+ with open(os.path.join(target_dir, "bobtemplate.cfg"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:addon",
@@ -85,9 +86,9 @@ def test_set_plone_version_variables(tmpdir):
[main]
version=5.1
"""
- target_dir = tmpdir.strpath + "/collective.foo"
+ target_dir = os.path.join(tmpdir.strpath, "collective.foo")
os.mkdir(target_dir)
- with open(os.path.join(target_dir + "/bobtemplate.cfg"), "w") as f:
+ with open(os.path.join(target_dir, "bobtemplate.cfg"), "w") as f:
f.write(template)
configurator = Configurator(
@@ -137,7 +138,9 @@ def test_set_plone_version_variables(tmpdir):
def test_dottedname_to_path():
dottedname = "collective.todo.content"
- assert base.dottedname_to_path(dottedname) == "collective/todo/content"
+ assert base.dottedname_to_path(dottedname) == os.path.join(
+ "collective", "todo", "content"
+ )
def test_subtemplate_warning(capsys):
@@ -149,7 +152,7 @@ def test_subtemplate_warning(capsys):
def test_is_string_in_file(tmpdir):
match_str = "-*- extra stuff goes here -*-"
- path = tmpdir.strpath + "/configure.zcml"
+ path = os.path.join(tmpdir.strpath, "configure.zcml")
template = """Some text
{0}
@@ -166,7 +169,7 @@ def test_is_string_in_file(tmpdir):
def test_update_configure_zcml(tmpdir):
file_name = "configure.zcml"
path = tmpdir.strpath
- file_path = path + "/" + file_name
+ file_path = os.path.join(path, file_name)
match_xpath = "zope:include[@package='.indexers']"
match_str = "-*- extra stuff goes here -*-"
insert_str = '\n '
@@ -250,14 +253,14 @@ def test_update_configure_zcml(tmpdir):
def test_update_file(tmpdir):
match_str = "-*- extra stuff goes here -*-"
- path = tmpdir.strpath + "/configure.zcml"
+ path = os.path.join(tmpdir.strpath, "configure.zcml")
template = """Some text
{0}
""".format(
match_str
)
- with open(os.path.join(path), "w") as f:
+ with open(path, "w") as f:
f.write(template)
base.update_file(None, path, match_str, "INSERTED")
@@ -313,12 +316,15 @@ def test_validate_packagename(tmpdir):
base.validate_packagename(configurator)
# step 7: test ending dot
- with pytest.raises(SystemExit):
- configurator = Configurator(
- template="bobtemplates.plone:addon",
- target_directory=os.path.join(base_path, "collective.foo."),
- )
- base.validate_packagename(configurator)
+ # skip this test on Win32, because Windows os.path.realpath implementation
+ # (i.e. nt._getfinalpathname) removes dots at the end of the path
+ if sys.platform != "win32":
+ with pytest.raises(SystemExit):
+ configurator = Configurator(
+ template="bobtemplates.plone:addon",
+ target_directory=os.path.join(base_path, "collective.foo."),
+ )
+ base.validate_packagename(configurator)
# step 8: test invalid char
with pytest.raises(SystemExit):
diff --git a/package_tests/test_behavior.py b/package_tests/test_behavior.py
index 1f4ecc4e..bf7f758a 100644
--- a/package_tests/test_behavior.py
+++ b/package_tests/test_behavior.py
@@ -20,9 +20,9 @@ def test_prepare_renderer():
def test_post_renderer(tmpdir):
- target_path = tmpdir.strpath + "/collective.todo"
- package_path = target_path + "/src/collective/todo"
- profiles_path = package_path + "/profiles/default"
+ target_path = os.path.join(tmpdir.strpath, "collective.todo")
+ package_path = os.path.join(target_path, "src", "collective", "todo")
+ profiles_path = os.path.join(package_path, "profiles", "default")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(profiles_path)
@@ -35,21 +35,21 @@ def test_post_renderer(tmpdir):
"""
- with open(os.path.join(profiles_path + "/metadata.xml"), "w") as f:
+ with open(os.path.join(profiles_path, "metadata.xml"), "w") as f:
f.write(template)
template = """
[main]
version=5.1
"""
- with open(os.path.join(target_path + "/bobtemplate.cfg"), "w") as f:
+ with open(os.path.join(target_path, "bobtemplate.cfg"), "w") as f:
f.write(template)
template = """
dummy
'-*- Extra requirements: -*-'
"""
- with open(os.path.join(target_path + "/setup.py"), "w") as f:
+ with open(os.path.join(target_path, "setup.py"), "w") as f:
f.write(template)
template = """
@@ -63,7 +63,7 @@ def test_post_renderer(tmpdir):
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:behavior",
diff --git a/package_tests/test_content_type.py b/package_tests/test_content_type.py
index 302df4c0..48d139cb 100644
--- a/package_tests/test_content_type.py
+++ b/package_tests/test_content_type.py
@@ -90,7 +90,7 @@ def test_prepare_renderer(tmpdir):
configurator.variables["dexterity_type_name_normalized"] == "special_task"
) # NOQA: E501
assert configurator.target_directory.endswith(
- "/collective.todo/src/collective/todo"
+ os.path.join("collective.todo", "src", "collective", "todo")
) # NOQA: E501
configurator = Configurator(
@@ -113,7 +113,7 @@ def test_prepare_renderer(tmpdir):
configurator.variables["dexterity_type_name_normalized"] == "special_task"
) # NOQA: E501
assert configurator.target_directory.endswith(
- "/collective.todo/src/collective/todo"
+ os.path.join("collective.todo", "src", "collective", "todo")
) # NOQA: E501
configurator = Configurator(
@@ -136,7 +136,7 @@ def test_prepare_renderer(tmpdir):
configurator.variables["dexterity_type_name_normalized"] == "special_task"
) # NOQA: E501
assert configurator.target_directory.endswith(
- "/collective.todo/src/collective/todo"
+ os.path.join("collective.todo", "src", "collective", "todo")
) # NOQA: E501
configurator = Configurator(
@@ -159,7 +159,7 @@ def test_prepare_renderer(tmpdir):
configurator.variables["dexterity_type_name_normalized"] == "special_task"
) # NOQA: E501
assert configurator.target_directory.endswith(
- "/collective.todo/src/collective/todo"
+ os.path.join("collective.todo", "src", "collective", "todo")
) # NOQA: E501
@@ -198,9 +198,9 @@ def test_check_global_allow_false():
def test_update_parent_types_fti_xml(tmpdir):
"""Test xml changes when changes are already in place."""
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- profiles_path = package_path + "/profiles/default/types"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ profiles_path = os.path.join(package_path, "profiles", "default", "types")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(profiles_path)
@@ -216,7 +216,7 @@ def test_update_parent_types_fti_xml(tmpdir):
"""
- with open(os.path.join(profiles_path + "/My_Parent.xml"), "w") as f:
+ with open(os.path.join(profiles_path, "My_Parent.xml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:content_type",
@@ -233,7 +233,7 @@ def test_update_parent_types_fti_xml(tmpdir):
configurator.variables["package_folder"] = package_path
content_type._update_parent_types_fti_xml(configurator)
- with open(os.path.join(profiles_path + "/My_Parent.xml"), "r") as f:
+ with open(os.path.join(profiles_path, "My_Parent.xml"), "r") as f:
content = f.read()
if content != template:
pytest.raises(ValidationError)
@@ -241,9 +241,9 @@ def test_update_parent_types_fti_xml(tmpdir):
def test_update_rolemap_xml(tmpdir):
"""Test rolemap.xml changes when changes are already in place."""
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- profiles_path = package_path + "/profiles/default"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ profiles_path = os.path.join(package_path, "profiles", "default")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(profiles_path)
@@ -261,7 +261,7 @@ def test_update_rolemap_xml(tmpdir):
"""
- with open(os.path.join(profiles_path + "/rolemap.xml"), "w") as f:
+ with open(os.path.join(profiles_path, "rolemap.xml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:content_type",
@@ -278,7 +278,7 @@ def test_update_rolemap_xml(tmpdir):
configurator.variables["dexterity_type_name_klass"] = "Parent"
content_type._update_rolemap_xml(configurator)
- with open(os.path.join(profiles_path + "/rolemap.xml"), "r") as f:
+ with open(os.path.join(profiles_path, "rolemap.xml"), "r") as f:
content = f.read()
if content != template:
pytest.raises(ValidationError)
@@ -286,8 +286,8 @@ def test_update_rolemap_xml(tmpdir):
def test_update_permissions_zcml(tmpdir):
"""Test zcml changes when changes are already in place."""
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
os.makedirs(target_path)
os.makedirs(package_path)
template = """
"""
- with open(os.path.join(package_path + "/permissions.zcml"), "w") as f:
+ with open(os.path.join(package_path, "permissions.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:content_type",
@@ -320,7 +320,7 @@ def test_update_permissions_zcml(tmpdir):
configurator.variables["dexterity_type_name_klass"] = "Parent"
content_type._update_permissions_zcml(configurator)
- with open(os.path.join(package_path + "/permissions.zcml"), "r") as f:
+ with open(os.path.join(package_path, "permissions.zcml"), "r") as f:
content = f.read()
if content != template:
pytest.raises(ValidationError)
@@ -328,12 +328,12 @@ def test_update_permissions_zcml(tmpdir):
def test_post_renderer(tmpdir):
"""Test post rendering."""
- target_path = tmpdir.strpath + "/collective.todo"
- package_path = target_path + "/src/collective/todo"
- profiles_path = package_path + "/profiles/default"
+ target_path = os.path.join(tmpdir.strpath, "collective.todo")
+ package_path = os.path.join(target_path, "src", "collective", "todo")
+ profiles_path = os.path.join(package_path, "profiles", "default")
os.makedirs(target_path)
os.makedirs(package_path)
- os.makedirs(profiles_path + "/types")
+ os.makedirs(os.path.join(profiles_path, "types"))
template = """
@@ -343,7 +343,7 @@ def test_post_renderer(tmpdir):
"""
- with open(os.path.join(profiles_path + "/metadata.xml"), "w") as f:
+ with open(os.path.join(profiles_path, "metadata.xml"), "w") as f:
f.write(template)
template = """
@@ -354,7 +354,7 @@ def test_post_renderer(tmpdir):
"""
- with open(os.path.join(profiles_path + "/rolemap.xml"), "w") as f:
+ with open(os.path.join(profiles_path, "rolemap.xml"), "w") as f:
f.write(template)
template = """
@@ -364,7 +364,7 @@ def test_post_renderer(tmpdir):
"""
- with open(os.path.join(profiles_path + "/types.xml"), "w") as f:
+ with open(os.path.join(profiles_path, "types.xml"), "w") as f:
f.write(template)
template = """
"""
- with open(os.path.join(package_path + "/permissions.zcml"), "w") as f:
+ with open(os.path.join(package_path, "permissions.zcml"), "w") as f:
f.write(template)
template = """
[main]
version=5.1
"""
- with open(os.path.join(target_path + "/bobtemplate.cfg"), "w") as f:
+ with open(os.path.join(target_path, "bobtemplate.cfg"), "w") as f:
f.write(template)
template = """
dummy
'-*- Extra requirements: -*-'
"""
- with open(os.path.join(target_path + "/setup.py"), "w") as f:
+ with open(os.path.join(target_path, "setup.py"), "w") as f:
f.write(template)
configurator = Configurator(
diff --git a/package_tests/test_form.py b/package_tests/test_form.py
index bd60c82f..08bb612a 100644
--- a/package_tests/test_form.py
+++ b/package_tests/test_form.py
@@ -25,9 +25,9 @@ def test_get_form_name():
def test_update_forms_configure_zcml(tmpdir):
"""Test configure changes when changes are already in place."""
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- forms_path = package_path + "/forms/"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ forms_path = os.path.join(package_path, "forms")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(forms_path)
@@ -41,7 +41,7 @@ def test_update_forms_configure_zcml(tmpdir):
"""
- with open(os.path.join(forms_path + "configure.zcml"), "w") as f:
+ with open(os.path.join(forms_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:form",
@@ -77,14 +77,14 @@ def test_update_forms_configure_zcml(tmpdir):
"""
- with open(os.path.join(forms_path + "configure.zcml"), "r") as f:
+ with open(os.path.join(forms_path, "configure.zcml"), "r") as f:
content = f.read()
assert content == expected
def test_update_configure_zcml(tmpdir):
- target_path = tmpdir.strpath + "/collective.demo"
- package_path = target_path + "/src/collective/demo"
+ target_path = os.path.join(tmpdir.strpath, "collective.demo")
+ package_path = os.path.join(target_path, "src", "collective", "demo")
os.makedirs(target_path)
os.makedirs(package_path)
template = """
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:form",
@@ -115,7 +115,7 @@ def test_update_configure_zcml(tmpdir):
def test_pre_renderer(tmpdir):
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
configurator = Configurator(
@@ -158,7 +158,7 @@ def test_pre_renderer(tmpdir):
def test_post_renderer(tmpdir):
"""Test post rendering."""
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
configurator = Configurator(
diff --git a/package_tests/test_indexer.py b/package_tests/test_indexer.py
index 6d909b33..d28d13e2 100644
--- a/package_tests/test_indexer.py
+++ b/package_tests/test_indexer.py
@@ -13,9 +13,9 @@
def test_update_indexers_configure_zcml(tmpdir):
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- indexers_path = package_path + "/indexers/"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ indexers_path = os.path.join(package_path, "indexers")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(indexers_path)
@@ -27,7 +27,7 @@ def test_update_indexers_configure_zcml(tmpdir):
"""
- with open(os.path.join(indexers_path + "configure.zcml"), "w") as f:
+ with open(os.path.join(indexers_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:indexer",
@@ -40,7 +40,7 @@ def test_update_indexers_configure_zcml(tmpdir):
)
indexer._update_indexers_configure_zcml(configurator)
- with open(os.path.join(indexers_path + "configure.zcml"), "r") as f:
+ with open(os.path.join(indexers_path, "configure.zcml"), "r") as f:
content = f.read()
if content != template:
pytest.raises(ValidationError)
@@ -62,7 +62,9 @@ def test_pre_renderer(tmpdir):
"indexer_name": "my_cool_index",
"package_folder": os.path.join(
package_root_folder,
- "src/collective/foo",
+ "src",
+ "collective",
+ "foo",
),
},
)
@@ -99,7 +101,7 @@ def test_post_renderer(tmpdir):
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
os.chdir(package_path)
diff --git a/package_tests/test_mockup_pattern.py b/package_tests/test_mockup_pattern.py
index a430bc99..f776978d 100644
--- a/package_tests/test_mockup_pattern.py
+++ b/package_tests/test_mockup_pattern.py
@@ -7,10 +7,14 @@
import os
import pytest
+import sys
+@pytest.mark.skipif(
+ sys.platform == "win32", reason="needs to fix mr.bob to run on windows"
+)
def test_pre_render(tmpdir):
- package_root = tmpdir.strpath + "/collective.testpattern"
+ package_root = os.path.join(tmpdir.strpath, "collective.testpattern")
package_path = init_package_base_structure(package_root)
configurator = Configurator(
@@ -27,8 +31,11 @@ def test_pre_render(tmpdir):
assert configurator.target_directory.endswith("collective.testpattern")
+@pytest.mark.skipif(
+ sys.platform == "win32", reason="needs to fix mr.bob to run on windows"
+)
def test_post_render(tmpdir):
- package_root = tmpdir.strpath + "/collective.testpattern"
+ package_root = os.path.join(tmpdir.strpath, "collective.testpattern")
package_path = init_package_base_structure(package_root)
configurator = Configurator(
@@ -53,11 +60,15 @@ def test_post_render(tmpdir):
configurator.render() # pre/render/post
+@pytest.mark.skipif(
+ sys.platform == "win32", reason="needs to fix mr.bob to run on windows"
+)
def test_post_pattern_name(tmpdir):
"""Verifies that pattern names are checked for validity."""
- target_path = tmpdir.strpath + "/collective.testpattern"
+ target_path = os.path.join(tmpdir.strpath, "collective.testpattern")
configurator = Configurator(
- template="bobtemplates.plone:mockup_pattern", target_directory=target_path
+ template="bobtemplates.plone:mockup_pattern",
+ target_directory=target_path,
)
mockup_pattern.post_pattern_name(configurator, None, "test-pattern")
diff --git a/package_tests/test_portlet.py b/package_tests/test_portlet.py
index 29e101f3..46891060 100644
--- a/package_tests/test_portlet.py
+++ b/package_tests/test_portlet.py
@@ -28,8 +28,8 @@ def test_pre_renderer():
def test_update_configure_zcml_with_changes(tmpdir):
"""Test configure changes when changes are already in place."""
- target_path = tmpdir.strpath + "/collective.demo"
- package_path = target_path + "/src/collective/demo"
+ target_path = os.path.join(tmpdir.strpath, "collective.demo")
+ package_path = os.path.join(target_path, "src", "collective", "demo")
os.makedirs(target_path)
os.makedirs(package_path)
template = """
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:portlet",
@@ -63,7 +63,7 @@ def test_update_configure_zcml_with_changes(tmpdir):
)
portlet._update_configure_zcml(configurator)
- with open(os.path.join(package_path + "/configure.zcml"), "r") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "r") as f:
content = f.read()
if content != template:
pytest.raises(ValidationError)
@@ -71,8 +71,8 @@ def test_update_configure_zcml_with_changes(tmpdir):
def test_update_configure_zcml_without_changes(tmpdir):
"""Test configure changes when changes are already in place."""
- target_path = tmpdir.strpath + "/collective.demo"
- package_path = target_path + "/src/collective/demo"
+ target_path = os.path.join(tmpdir.strpath, "collective.demo")
+ package_path = os.path.join(target_path, "src", "collective", "demo")
os.makedirs(target_path)
os.makedirs(package_path)
template = """
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:portlet",
@@ -122,7 +122,7 @@ def test_update_configure_zcml_without_changes(tmpdir):
"""
- with open(os.path.join(package_path + "/configure.zcml"), "r") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "r") as f:
content = f.read()
if content != complete_template:
pytest.raises(ValidationError)
@@ -130,9 +130,9 @@ def test_update_configure_zcml_without_changes(tmpdir):
def test_update_portlets_configure_zcml(tmpdir):
"""Test configure changes when changes are already in place."""
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- portlets_path = package_path + "/portlets/"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ portlets_path = os.path.join(package_path, "portlets")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(portlets_path)
@@ -154,7 +154,7 @@ def test_update_portlets_configure_zcml(tmpdir):
"""
- with open(os.path.join(portlets_path + "configure.zcml"), "w") as f:
+ with open(os.path.join(portlets_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:portlet",
@@ -173,7 +173,7 @@ def test_update_portlets_configure_zcml(tmpdir):
)
portlet._update_portlets_configure_zcml(configurator)
- with open(os.path.join(portlets_path + "configure.zcml"), "r") as f:
+ with open(os.path.join(portlets_path, "configure.zcml"), "r") as f:
content = f.read()
if content != template:
pytest.raises(ValidationError)
@@ -181,19 +181,19 @@ def test_update_portlets_configure_zcml(tmpdir):
def test_delete_unnecessary_files(tmpdir):
"""Test to remove unwanted file."""
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- portlets_path = package_path + "/portlets/"
- profile_path = package_path + "/profiles/default/"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ portlets_path = os.path.join(package_path, "portlets")
+ profile_path = os.path.join(package_path, "profiles", "default")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(portlets_path)
os.makedirs(profile_path)
file_name = "configure.zcml.example"
- portlets_file_path = portlets_path + file_name
+ portlets_file_path = os.path.join(portlets_path, file_name)
open(portlets_file_path, "a").close()
file_name = "portlets.xml.example"
- xml_file_path = profile_path + file_name
+ xml_file_path = os.path.join(profile_path, file_name)
open(xml_file_path, "a").close()
configurator = Configurator(
template="bobtemplates.plone:portlet",
@@ -213,9 +213,9 @@ def test_delete_unnecessary_files(tmpdir):
def test_update_portlets_xml(tmpdir):
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- profile_path = package_path + "/profiles/default/"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ profile_path = os.path.join(package_path, "profiles", "default")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(profile_path)
@@ -227,7 +227,7 @@ def test_update_portlets_xml(tmpdir):
"""
- with open(os.path.join(profile_path + "portlets.xml.example"), "w") as f:
+ with open(os.path.join(profile_path, "portlets.xml.example"), "w") as f:
f.write(template)
configurator = Configurator(
@@ -273,16 +273,16 @@ def test_update_portlets_xml(tmpdir):
"""
- with open(os.path.join(profile_path + "portlets.xml"), "r") as f:
+ with open(os.path.join(profile_path, "portlets.xml"), "r") as f:
content = f.read()
if content != template:
pytest.raises(ValidationError)
def test_update_portlets_xml_with_changes(tmpdir):
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- profile_path = package_path + "/profiles/default/"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ profile_path = os.path.join(package_path, "profiles", "default")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(profile_path)
@@ -313,7 +313,7 @@ def test_update_portlets_xml_with_changes(tmpdir):
"""
- with open(os.path.join(profile_path + "portlets.xml.example"), "w") as f:
+ with open(os.path.join(profile_path, "portlets.xml.example"), "w") as f:
f.write(template)
configurator = Configurator(
@@ -331,7 +331,7 @@ def test_update_portlets_xml_with_changes(tmpdir):
)
portlet._update_portlets_xml(configurator)
- with open(os.path.join(profile_path + "portlets.xml"), "r") as f:
+ with open(os.path.join(profile_path, "portlets.xml"), "r") as f:
content = f.read()
if content != template:
pytest.raises(ValidationError)
@@ -339,10 +339,10 @@ def test_update_portlets_xml_with_changes(tmpdir):
def test_post_renderer(tmpdir):
"""Test post rendering."""
- target_path = tmpdir.strpath + "/collective.todo"
- package_path = target_path + "/src/collective/todo"
- portlets_path = package_path + "/portlets"
- profile_path = package_path + "/profiles/default/"
+ target_path = os.path.join(tmpdir.strpath, "collective.todo")
+ package_path = os.path.join(target_path, "src", "collective", "todo")
+ portlets_path = os.path.join(package_path, "portlets")
+ profile_path = os.path.join(package_path, "profiles", "default")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(portlets_path)
@@ -436,7 +436,7 @@ def get_humidity(self):
def get_pressure(self):
return self.result['pressure']
"""
- with open(os.path.join(portlets_path + "/my_weather.py"), "w") as f:
+ with open(os.path.join(portlets_path, "my_weather.py"), "w") as f:
f.write(template)
template = """
@@ -449,7 +449,7 @@ def get_pressure(self):
"""
- with open(os.path.join(portlets_path + "/my_weather.pt"), "w") as f:
+ with open(os.path.join(portlets_path, "my_weather.pt"), "w") as f:
f.write(template)
template = """
"""
- with open(os.path.join(portlets_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(portlets_path, "configure.zcml"), "w") as f:
f.write(template)
template = """
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
template = """
dummy
'-*- Extra requirements: -*-'
"""
- with open(os.path.join(target_path + "/setup.py"), "w") as f:
+ with open(os.path.join(target_path, "setup.py"), "w") as f:
f.write(template)
template = """
@@ -530,7 +530,7 @@ def get_pressure(self):
"""
- with open(os.path.join(profile_path + "/portlets.xml.example"), "w") as f:
+ with open(os.path.join(profile_path, "portlets.xml.example"), "w") as f:
f.write(template)
configurator = Configurator(
diff --git a/package_tests/test_restapi_service.py b/package_tests/test_restapi_service.py
index 648801f5..21dfa4a4 100644
--- a/package_tests/test_restapi_service.py
+++ b/package_tests/test_restapi_service.py
@@ -8,22 +8,22 @@
def test_pre_renderer(tmpdir):
- target_path = tmpdir.strpath + "/collective.todo"
- package_path = target_path + "/src/collective/todo"
+ target_path = os.path.join(tmpdir.strpath, "collective.todo")
+ package_path = os.path.join(target_path, "src", "collective", "todo")
os.makedirs(target_path)
os.makedirs(package_path)
template = """
[main]
version=5.1
"""
- with open(os.path.join(target_path + "/bobtemplate.cfg"), "w") as f:
+ with open(os.path.join(target_path, "bobtemplate.cfg"), "w") as f:
f.write(template)
template = """
dummy
'-*- Extra requirements: -*-'
"""
- with open(os.path.join(target_path + "/setup.py"), "w") as f:
+ with open(os.path.join(target_path, "setup.py"), "w") as f:
f.write(template)
configurator = Configurator(
@@ -39,9 +39,9 @@ def test_pre_renderer(tmpdir):
def test_post_renderer(tmpdir):
- target_path = tmpdir.strpath + "/collective.todo"
- package_path = target_path + "/src/collective/todo"
- profiles_path = package_path + "/profiles/default"
+ target_path = os.path.join(tmpdir.strpath, "collective.todo")
+ package_path = os.path.join(target_path, "src", "collective", "todo")
+ profiles_path = os.path.join(package_path, "profiles", "default")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(profiles_path)
@@ -54,21 +54,21 @@ def test_post_renderer(tmpdir):
"""
- with open(os.path.join(profiles_path + "/metadata.xml"), "w") as f:
+ with open(os.path.join(profiles_path, "metadata.xml"), "w") as f:
f.write(template)
template = """
[main]
version=5.1
"""
- with open(os.path.join(target_path + "/bobtemplate.cfg"), "w") as f:
+ with open(os.path.join(target_path, "bobtemplate.cfg"), "w") as f:
f.write(template)
template = """
dummy
'-*- Extra requirements: -*-'
"""
- with open(os.path.join(target_path + "/setup.py"), "w") as f:
+ with open(os.path.join(target_path, "setup.py"), "w") as f:
f.write(template)
template = """
@@ -82,7 +82,7 @@ def test_post_renderer(tmpdir):
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
@@ -108,12 +108,12 @@ def test_post_renderer(tmpdir):
def test_remove_unwanted_files(tmpdir):
files_to_remove = [
- "/api/configure.zcml.example",
- "/api/services/configure.zcml.example",
+ "api/configure.zcml.example",
+ "api/services/configure.zcml.example",
]
- target_path = tmpdir.strpath + "/collective.todo"
- package_path = target_path + "/src/collective/todo"
- os.makedirs(package_path + "/api/services/")
+ target_path = os.path.join(tmpdir.strpath, "collective.todo")
+ package_path = os.path.join(target_path, "src", "collective", "todo")
+ os.makedirs(os.path.join(package_path, "api", "services"))
configurator = Configurator(
template="bobtemplates.plone:restapi_service",
target_directory=tmpdir.strpath,
@@ -124,7 +124,8 @@ def test_remove_unwanted_files(tmpdir):
for file_to_remove in files_to_remove:
with open(
os.path.join(
- package_path + file_to_remove,
+ package_path,
+ *file_to_remove.split("/"),
),
"w",
) as f:
@@ -133,28 +134,28 @@ def test_remove_unwanted_files(tmpdir):
for file_to_remove in files_to_remove:
assert not os.path.isfile(
- os.path.join(package_path + file_to_remove),
+ os.path.join(package_path, *file_to_remove.split("/")),
)
def test_update_api_configure_zcml(tmpdir):
""" """
- target_path = tmpdir.strpath + "/collective.todo"
- package_path = target_path + "/src/collective/todo"
- os.makedirs(package_path + "/api/")
+ target_path = os.path.join(tmpdir.strpath, "collective.todo")
+ package_path = os.path.join(target_path, "src", "collective", "todo")
+ os.makedirs(os.path.join(package_path, "api"))
template = """
[main]
version=5.1
"""
- with open(os.path.join(target_path + "/bobtemplate.cfg"), "w") as f:
+ with open(os.path.join(target_path, "bobtemplate.cfg"), "w") as f:
f.write(template)
template = """
dummy
'-*- Extra requirements: -*-'
"""
- with open(os.path.join(target_path + "/setup.py"), "w") as f:
+ with open(os.path.join(target_path, "setup.py"), "w") as f:
f.write(template)
template = """
@@ -168,9 +169,9 @@ def test_update_api_configure_zcml(tmpdir):
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
- with open(os.path.join(package_path + "/api/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "api", "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:restapi_service",
@@ -189,7 +190,9 @@ def test_update_api_configure_zcml(tmpdir):
with open(
os.path.join(
- package_path + "/api/configure.zcml",
+ package_path,
+ "api",
+ "configure.zcml",
),
"r",
) as f:
@@ -199,22 +202,22 @@ def test_update_api_configure_zcml(tmpdir):
def test_update_services_configure_zcml(tmpdir):
""" """
- target_path = tmpdir.strpath + "/collective.todo"
- package_path = target_path + "/src/collective/todo"
- os.makedirs(package_path + "/api/services/")
+ target_path = os.path.join(tmpdir.strpath, "collective.todo")
+ package_path = os.path.join(target_path, "src", "collective", "todo")
+ os.makedirs(os.path.join(package_path, "api", "services"))
template = """
[main]
version=5.1
"""
- with open(os.path.join(target_path + "/bobtemplate.cfg"), "w") as f:
+ with open(os.path.join(target_path, "bobtemplate.cfg"), "w") as f:
f.write(template)
template = """
dummy
'-*- Extra requirements: -*-'
"""
- with open(os.path.join(target_path + "/setup.py"), "w") as f:
+ with open(os.path.join(target_path, "setup.py"), "w") as f:
f.write(template)
template = """
@@ -228,12 +231,12 @@ def test_update_services_configure_zcml(tmpdir):
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
- with open(os.path.join(package_path + "/api/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "api", "configure.zcml"), "w") as f:
f.write(template)
with open(
- os.path.join(package_path + "/api/services/configure.zcml"),
+ os.path.join(package_path, "api", "services", "configure.zcml"),
"w",
) as f:
f.write(template)
@@ -255,7 +258,10 @@ def test_update_services_configure_zcml(tmpdir):
with open(
os.path.join(
- package_path + "/api/services/configure.zcml",
+ package_path,
+ "api",
+ "services",
+ "configure.zcml",
),
"r",
) as f:
diff --git a/package_tests/test_subscriber.py b/package_tests/test_subscriber.py
index 9b69daef..0fdab121 100644
--- a/package_tests/test_subscriber.py
+++ b/package_tests/test_subscriber.py
@@ -13,9 +13,9 @@
def test_update_subscribers_configure_zcml(tmpdir):
"""Test configure changes when changes are already in place."""
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- subscribers_path = package_path + "/subscribers/"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ subscribers_path = os.path.join(package_path, "subscribers")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(subscribers_path)
@@ -32,7 +32,7 @@ def test_update_subscribers_configure_zcml(tmpdir):
"""
- with open(os.path.join(subscribers_path + "configure.zcml"), "w") as f:
+ with open(os.path.join(subscribers_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:subscriber",
@@ -46,7 +46,7 @@ def test_update_subscribers_configure_zcml(tmpdir):
)
subscriber._update_subscribers_configure_zcml(configurator)
- with open(os.path.join(subscribers_path + "configure.zcml"), "r") as f:
+ with open(os.path.join(subscribers_path, "configure.zcml"), "r") as f:
content = f.read()
if content != template:
pytest.raises(ValidationError)
diff --git a/package_tests/test_svelte_app.py b/package_tests/test_svelte_app.py
index 8ef66ba6..c5e4e654 100644
--- a/package_tests/test_svelte_app.py
+++ b/package_tests/test_svelte_app.py
@@ -12,7 +12,7 @@
def test_prep_renderer(tmpdir):
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
init_package_base_structure(package_root)
configurator = Configurator(
template="bobtemplates.plone:svelte_app",
@@ -25,7 +25,7 @@ def test_prep_renderer(tmpdir):
def test_check_name(tmpdir):
- target_path = tmpdir.strpath + "/collective.todo"
+ target_path = os.path.join(tmpdir.strpath, "collective.todo")
question = Question(
name="svelte_app_name", question="Name of your Svelte app", default=None
)
@@ -60,9 +60,9 @@ def test_check_name(tmpdir):
def test_post_renderer(tmpdir):
- target_path = tmpdir.strpath + "/collective.todo"
- package_path = target_path + "/src/collective/todo"
- profiles_path = package_path + "/profiles/default"
+ target_path = os.path.join(tmpdir.strpath, "collective.todo")
+ package_path = os.path.join(target_path, "src", "collective", "todo")
+ profiles_path = os.path.join(package_path, "profiles", "default")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(profiles_path)
@@ -75,21 +75,21 @@ def test_post_renderer(tmpdir):
"""
- with open(os.path.join(profiles_path + "/metadata.xml"), "w") as f:
+ with open(os.path.join(profiles_path, "metadata.xml"), "w") as f:
f.write(template)
template = """
[main]
version=5.1
"""
- with open(os.path.join(target_path + "/bobtemplate.cfg"), "w") as f:
+ with open(os.path.join(target_path, "bobtemplate.cfg"), "w") as f:
f.write(template)
template = """
dummy
'-*- Extra requirements: -*-'
"""
- with open(os.path.join(target_path + "/setup.py"), "w") as f:
+ with open(os.path.join(target_path, "setup.py"), "w") as f:
f.write(template)
template = """
@@ -103,7 +103,7 @@ def test_post_renderer(tmpdir):
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:svelte_app",
diff --git a/package_tests/test_theme.py b/package_tests/test_theme.py
index cd98038c..9e0a4578 100644
--- a/package_tests/test_theme.py
+++ b/package_tests/test_theme.py
@@ -44,7 +44,7 @@ def test_post_theme_name(tmpdir):
def test_prepare_renderer(tmpdir):
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
configurator = Configurator(
@@ -59,7 +59,7 @@ def test_prepare_renderer(tmpdir):
assert configurator.variables["template_id"] == "theme"
assert configurator.variables["theme.normalized_name"] == "my-beautiful-theme-2021"
assert configurator.target_directory.endswith(
- "/collective.todo/src/collective/todo"
+ os.path.join("", "collective.todo", "src", "collective", "todo")
) # NOQA: E501
# nested namespace package
@@ -81,12 +81,12 @@ def test_prepare_renderer(tmpdir):
assert configurator.variables["template_id"] == "theme"
assert configurator.variables["theme.normalized_name"] == "my-beautiful-theme-2021"
assert configurator.target_directory.endswith(
- "/collective.foo.bar/src/collective/foo/bar"
+ os.path.join("", "collective.foo.bar", "src", "collective", "foo", "bar")
) # NOQA: E501
def test_post_renderer(tmpdir):
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
configurator = Configurator(
diff --git a/package_tests/test_theme_barceloneta.py b/package_tests/test_theme_barceloneta.py
index bcd2dd02..db1f142b 100644
--- a/package_tests/test_theme_barceloneta.py
+++ b/package_tests/test_theme_barceloneta.py
@@ -22,7 +22,7 @@ def test_pre_theme_name():
def test_post_theme_name(tmpdir):
- target_path = tmpdir.strpath + "/collective.theme"
+ target_path = os.path.join(tmpdir.strpath, "collective.theme")
configurator = Configurator(
template="bobtemplates.plone:theme_barceloneta", target_directory=target_path
)
@@ -33,7 +33,7 @@ def test_post_theme_name(tmpdir):
def test_prepare_renderer(tmpdir):
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
configurator = Configurator(
@@ -51,7 +51,7 @@ def test_prepare_renderer(tmpdir):
def test_post_renderer(tmpdir):
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
configurator = Configurator(
diff --git a/package_tests/test_theme_basic.py b/package_tests/test_theme_basic.py
index 8482d805..33a51be8 100644
--- a/package_tests/test_theme_basic.py
+++ b/package_tests/test_theme_basic.py
@@ -22,7 +22,7 @@ def test_pre_theme_name():
def test_post_theme_name(tmpdir):
- target_path = tmpdir.strpath + "/collective.theme"
+ target_path = os.path.join(tmpdir.strpath, "collective.theme")
configurator = Configurator(
template="bobtemplates.plone:theme_basic", target_directory=target_path
)
@@ -33,7 +33,7 @@ def test_post_theme_name(tmpdir):
def test_prepare_renderer(tmpdir):
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
configurator = Configurator(
@@ -51,7 +51,7 @@ def test_prepare_renderer(tmpdir):
def test_post_renderer(tmpdir):
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
configurator = Configurator(
diff --git a/package_tests/test_upgrade_step.py b/package_tests/test_upgrade_step.py
index 237e600e..ecca8e2f 100644
--- a/package_tests/test_upgrade_step.py
+++ b/package_tests/test_upgrade_step.py
@@ -9,9 +9,9 @@
def test_pre_renderer(tmpdir):
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
- target_path = os.path.join(package_path, "profiles/default")
+ target_path = os.path.join(package_path, "profiles", "default")
template = """
@@ -40,9 +40,9 @@ def test_pre_renderer(tmpdir):
def test_post_renderer(tmpdir):
- target_path = tmpdir.strpath + "/collective.todo"
- package_path = target_path + "/src/collective/todo"
- profiles_path = package_path + "/profiles/default"
+ target_path = os.path.join(tmpdir.strpath, "collective.todo")
+ package_path = os.path.join(target_path, "src", "collective", "todo")
+ profiles_path = os.path.join(package_path, "profiles", "default")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(profiles_path)
@@ -55,21 +55,21 @@ def test_post_renderer(tmpdir):
"""
- with open(os.path.join(profiles_path + "/metadata.xml"), "w") as f:
+ with open(os.path.join(profiles_path, "metadata.xml"), "w") as f:
f.write(template)
template = """
[main]
version=5.1
"""
- with open(os.path.join(target_path + "/bobtemplate.cfg"), "w") as f:
+ with open(os.path.join(target_path, "bobtemplate.cfg"), "w") as f:
f.write(template)
template = """
dummy
'-*- Extra requirements: -*-'
"""
- with open(os.path.join(target_path + "/setup.py"), "w") as f:
+ with open(os.path.join(target_path, "setup.py"), "w") as f:
f.write(template)
template = """
@@ -83,7 +83,7 @@ def test_post_renderer(tmpdir):
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:upgrade_step",
@@ -105,7 +105,7 @@ def test_post_renderer(tmpdir):
def test_read_source_version(tmpdir):
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
target_path = os.path.join(package_path, "profiles/default")
@@ -137,9 +137,9 @@ def test_read_source_version(tmpdir):
def test_write_dest_version(tmpdir):
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
- target_path = os.path.join(package_path, "profiles/default")
+ target_path = os.path.join(package_path, "profiles", "default")
template = """
diff --git a/package_tests/test_view.py b/package_tests/test_view.py
index d3d99c67..52fc137a 100644
--- a/package_tests/test_view.py
+++ b/package_tests/test_view.py
@@ -93,9 +93,9 @@ def test_view_template_and_python_class_false():
def test_update_views_configure_zcml(tmpdir):
"""Test configure changes when changes are already in place."""
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- views_path = package_path + "/views/"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ views_path = os.path.join(package_path, "views")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(views_path)
@@ -109,7 +109,7 @@ def test_update_views_configure_zcml(tmpdir):
"""
- with open(os.path.join(views_path + "configure.zcml"), "w") as f:
+ with open(os.path.join(views_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:view",
@@ -149,16 +149,16 @@ def test_update_views_configure_zcml(tmpdir):
"""
- with open(os.path.join(views_path + "configure.zcml"), "r") as f:
+ with open(os.path.join(views_path, "configure.zcml"), "r") as f:
content = f.read()
assert content == expected
def test_update_views_configure_zcml_without_template(tmpdir):
"""Test configure changes when changes are already in place."""
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- views_path = package_path + "/views/"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ views_path = os.path.join(package_path, "views")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(views_path)
@@ -172,7 +172,7 @@ def test_update_views_configure_zcml_without_template(tmpdir):
"""
- with open(os.path.join(views_path + "configure.zcml"), "w") as f:
+ with open(os.path.join(views_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:view",
@@ -210,16 +210,16 @@ def test_update_views_configure_zcml_without_template(tmpdir):
"""
- with open(os.path.join(views_path + "configure.zcml"), "r") as f:
+ with open(os.path.join(views_path, "configure.zcml"), "r") as f:
content = f.read()
assert content == expected
def test_update_views_configure_zcml_without_python_class(tmpdir):
"""Test configure changes when changes are already in place."""
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- views_path = package_path + "/views/"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ views_path = os.path.join(package_path, "views")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(views_path)
@@ -233,7 +233,7 @@ def test_update_views_configure_zcml_without_python_class(tmpdir):
"""
- with open(os.path.join(views_path + "configure.zcml"), "w") as f:
+ with open(os.path.join(views_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:view",
@@ -271,15 +271,15 @@ def test_update_views_configure_zcml_without_python_class(tmpdir):
"""
- with open(os.path.join(views_path + "configure.zcml"), "r") as f:
+ with open(os.path.join(views_path, "configure.zcml"), "r") as f:
content = f.read()
assert content == expected
def test_delete_unwanted_files_template(tmpdir):
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
- views_path = os.path.join(package_path + "/views/")
+ views_path = os.path.join(package_path, "views")
configurator = Configurator(
template="bobtemplates.plone:view",
@@ -299,19 +299,19 @@ def test_delete_unwanted_files_template(tmpdir):
os.chdir(package_path)
base.set_global_vars(configurator)
configurator.render() # pre/render/post
- # as the post_rederer also calls delete_unwanted_files. we don't need to call here
+ # as the post_rederer also calls delete_unwantd_files. we don't need to call here
python_file_name = configurator.variables.get("view_python_file_name") + ".py"
template_file_name = configurator.variables.get("view_template_name") + ".pt"
- python_file_path = os.path.join(views_path + python_file_name)
- template_file_path = os.path.join(views_path + template_file_name)
+ python_file_path = os.path.join(views_path, python_file_name)
+ template_file_path = os.path.join(views_path, template_file_name)
assert os.path.isfile(template_file_path)
assert not os.path.isfile(python_file_path)
def test_delete_unwanted_files_python(tmpdir):
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
- views_path = os.path.join(package_path + "/views/")
+ views_path = os.path.join(package_path, "views")
configurator = Configurator(
template="bobtemplates.plone:view",
@@ -334,15 +334,15 @@ def test_delete_unwanted_files_python(tmpdir):
# as the post_rederer also calls delete_unwanted_files. we don't need to call here
python_file_name = configurator.variables.get("view_python_file_name") + ".py"
template_file_name = configurator.variables.get("view_template_name") + ".pt"
- python_file_path = os.path.join(views_path + python_file_name)
- template_file_path = os.path.join(views_path + template_file_name)
+ python_file_path = os.path.join(views_path, python_file_name)
+ template_file_path = os.path.join(views_path, template_file_name)
assert not os.path.isfile(template_file_path)
assert os.path.isfile(python_file_path)
def test_update_configure_zcml(tmpdir):
- target_path = tmpdir.strpath + "/collective.demo"
- package_path = target_path + "/src/collective/demo"
+ target_path = os.path.join(tmpdir.strpath, "collective.demo")
+ package_path = os.path.join(target_path, "src", "collective", "demo")
os.makedirs(target_path)
os.makedirs(package_path)
template = """
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:view",
@@ -372,7 +372,7 @@ def test_update_configure_zcml(tmpdir):
def test_pre_renderer(tmpdir):
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
configurator = Configurator(
@@ -425,7 +425,7 @@ def test_pre_renderer(tmpdir):
def test_post_renderer(tmpdir):
"""Test post rendering."""
- package_root = tmpdir.strpath + "/collective.todo"
+ package_root = os.path.join(tmpdir.strpath, "collective.todo")
package_path = init_package_base_structure(package_root)
configurator = Configurator(
diff --git a/package_tests/test_viewlet.py b/package_tests/test_viewlet.py
index 1b3f90cf..f8e4ae07 100644
--- a/package_tests/test_viewlet.py
+++ b/package_tests/test_viewlet.py
@@ -59,8 +59,8 @@ def test_viewlet_template_false():
def test_update_configure_zcml(tmpdir):
"""Test configure changes when changes are already in place."""
- target_path = tmpdir.strpath + "/collective.demo"
- package_path = target_path + "/src/collective/demo"
+ target_path = os.path.join(tmpdir.strpath, "collective.demo")
+ package_path = os.path.join(target_path, "src", "collective", "demo")
os.makedirs(target_path)
os.makedirs(package_path)
template = """
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:viewlet",
@@ -94,7 +94,7 @@ def test_update_configure_zcml(tmpdir):
)
viewlet._update_configure_zcml(configurator)
- with open(os.path.join(package_path + "/configure.zcml"), "r") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "r") as f:
content = f.read()
if content != template:
pytest.raises(ValidationError)
@@ -102,9 +102,9 @@ def test_update_configure_zcml(tmpdir):
def test_update_viewlets_configure_zcml_with_template(tmpdir):
"""Test configure changes when changes are already in place."""
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- viewlets_path = package_path + "/viewlets/"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ viewlets_path = os.path.join(package_path, "viewlets")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(viewlets_path)
@@ -128,7 +128,7 @@ def test_update_viewlets_configure_zcml_with_template(tmpdir):
"""
- with open(os.path.join(viewlets_path + "configure.zcml"), "w") as f:
+ with open(os.path.join(viewlets_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:viewlet",
@@ -149,7 +149,7 @@ def test_update_viewlets_configure_zcml_with_template(tmpdir):
)
viewlet._update_viewlets_configure_zcml(configurator)
- with open(os.path.join(viewlets_path + "configure.zcml"), "r") as f:
+ with open(os.path.join(viewlets_path, "configure.zcml"), "r") as f:
content = f.read()
if content != template:
pytest.raises(ValidationError)
@@ -157,9 +157,9 @@ def test_update_viewlets_configure_zcml_with_template(tmpdir):
def test_update_viewlets_configure_zcml_without_template(tmpdir):
"""Test configure changes when changes are already in place."""
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- viewlets_path = package_path + "/viewlets/"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ viewlets_path = os.path.join(package_path, "viewlets")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(viewlets_path)
@@ -182,7 +182,7 @@ def test_update_viewlets_configure_zcml_without_template(tmpdir):
"""
- with open(os.path.join(viewlets_path + "configure.zcml"), "w") as f:
+ with open(os.path.join(viewlets_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:viewlet",
@@ -202,7 +202,7 @@ def test_update_viewlets_configure_zcml_without_template(tmpdir):
)
viewlet._update_viewlets_configure_zcml(configurator)
- with open(os.path.join(viewlets_path + "configure.zcml"), "r") as f:
+ with open(os.path.join(viewlets_path, "configure.zcml"), "r") as f:
content = f.read()
if content != template:
pytest.raises(ValidationError)
@@ -210,17 +210,15 @@ def test_update_viewlets_configure_zcml_without_template(tmpdir):
def test_delete_template_file(tmpdir):
"""Test to remove unwanted file."""
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- viewlets_path = package_path + "/viewlets/"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ viewlets_path = os.path.join(package_path, "viewlets")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(viewlets_path)
- file_name = "configure.zcml.example"
- file_path = viewlets_path + file_name
+ file_path = os.path.join(viewlets_path, "configure.zcml.example")
open(file_path, "a").close()
- file_name = "my_viewlet.pt"
- file_path = viewlets_path + file_name
+ file_path = os.path.join(viewlets_path, "my_viewlet.pt")
open(file_path, "a").close()
configurator = Configurator(
template="bobtemplates.plone:viewlet",
@@ -242,17 +240,15 @@ def test_delete_template_file(tmpdir):
def test_delete_template_file_false(tmpdir):
"""Test to not remove template file."""
- target_path = tmpdir.strpath + "/collective.sample"
- package_path = target_path + "/src/collective/sample"
- viewlets_path = package_path + "/viewlets/"
+ target_path = os.path.join(tmpdir.strpath, "collective.sample")
+ package_path = os.path.join(target_path, "src", "collective", "sample")
+ viewlets_path = os.path.join(package_path, "viewlets")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(viewlets_path)
- file_name = "configure.zcml.example"
- file_path = viewlets_path + file_name
+ file_path = os.path.join(viewlets_path, "configure.zcml.example")
open(file_path, "a").close()
- file_name = "my_viewlet.pt"
- file_path = viewlets_path + file_name
+ file_path = os.path.join(viewlets_path, "my_viewlet.pt")
open(file_path, "a").close()
configurator = Configurator(
template="bobtemplates.plone:viewlet",
@@ -274,9 +270,9 @@ def test_delete_template_file_false(tmpdir):
def test_post_renderer_with_template(tmpdir):
"""Test post rendering."""
- target_path = tmpdir.strpath + "/collective.todo"
- package_path = target_path + "/src/collective/todo"
- viewlets_path = package_path + "/viewlets"
+ target_path = os.path.join(tmpdir.strpath, "collective.todo")
+ package_path = os.path.join(target_path, "src", "collective", "todo")
+ viewlets_path = os.path.join(package_path, "viewlets")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(viewlets_path)
@@ -292,13 +288,13 @@ def render(self):
return u'Sample viewlet!'
"""
- with open(os.path.join(viewlets_path + "/viewlet.py"), "w") as f:
+ with open(os.path.join(viewlets_path, "viewlet.py"), "w") as f:
f.write(template)
template = """
${view/get_message}
"""
- with open(os.path.join(viewlets_path + "/viewlet.pt"), "w") as f:
+ with open(os.path.join(viewlets_path, "viewlet.pt"), "w") as f:
f.write(template)
template = """
"""
- with open(os.path.join(viewlets_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(viewlets_path, "configure.zcml"), "w") as f:
f.write(template)
template = """
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
@@ -364,7 +360,7 @@ def render(self):
dummy
'-*- Extra requirements: -*-'
"""
- with open(os.path.join(target_path + "/setup.py"), "w") as f:
+ with open(os.path.join(target_path, "setup.py"), "w") as f:
f.write(template)
os.chdir(package_path)
@@ -375,9 +371,9 @@ def render(self):
def test_post_renderer_without_template(tmpdir):
"""Test post rendering."""
- target_path = tmpdir.strpath + "/collective.todo"
- package_path = target_path + "/src/collective/todo"
- viewlets_path = package_path + "/viewlets"
+ target_path = os.path.join(tmpdir.strpath, "collective.todo")
+ package_path = os.path.join(target_path, "src", "collective", "todo")
+ viewlets_path = os.path.join(package_path, "viewlets")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(viewlets_path)
@@ -393,13 +389,13 @@ def render(self):
return u'Sample viewlet!'
"""
- with open(os.path.join(viewlets_path + "/viewlet.py"), "w") as f:
+ with open(os.path.join(viewlets_path, "viewlet.py"), "w") as f:
f.write(template)
template = """
${view/get_message}
"""
- with open(os.path.join(viewlets_path + "/viewlet.pt"), "w") as f:
+ with open(os.path.join(viewlets_path, "viewlet.pt"), "w") as f:
f.write(template)
template = """
"""
- with open(os.path.join(viewlets_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(viewlets_path, "configure.zcml"), "w") as f:
f.write(template)
template = """
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
@@ -464,7 +460,7 @@ def render(self):
dummy
'-*- Extra requirements: -*-'
"""
- with open(os.path.join(target_path + "/setup.py"), "w") as f:
+ with open(os.path.join(target_path, "setup.py"), "w") as f:
f.write(template)
os.chdir(package_path)
diff --git a/package_tests/test_vocabulary.py b/package_tests/test_vocabulary.py
index 785fcf1d..e5d2cf89 100644
--- a/package_tests/test_vocabulary.py
+++ b/package_tests/test_vocabulary.py
@@ -19,9 +19,9 @@ def test_prepare_renderer():
def test_post_renderer(tmpdir):
- target_path = tmpdir.strpath + "/collective.todo"
- package_path = target_path + "/src/collective/todo"
- profiles_path = package_path + "/profiles/default"
+ target_path = os.path.join(tmpdir.strpath, "collective.todo")
+ package_path = os.path.join(target_path, "src", "collective", "todo")
+ profiles_path = os.path.join(package_path, "profiles", "default")
os.makedirs(target_path)
os.makedirs(package_path)
os.makedirs(profiles_path)
@@ -34,21 +34,21 @@ def test_post_renderer(tmpdir):
"""
- with open(os.path.join(profiles_path + "/metadata.xml"), "w") as f:
+ with open(os.path.join(profiles_path, "metadata.xml"), "w") as f:
f.write(template)
template = """
[main]
version=5.1
"""
- with open(os.path.join(target_path + "/bobtemplate.cfg"), "w") as f:
+ with open(os.path.join(target_path, "bobtemplate.cfg"), "w") as f:
f.write(template)
template = """
dummy
'-*- Extra requirements: -*-'
"""
- with open(os.path.join(target_path + "/setup.py"), "w") as f:
+ with open(os.path.join(target_path, "setup.py"), "w") as f:
f.write(template)
template = """
@@ -62,7 +62,7 @@ def test_post_renderer(tmpdir):
"""
- with open(os.path.join(package_path + "/configure.zcml"), "w") as f:
+ with open(os.path.join(package_path, "configure.zcml"), "w") as f:
f.write(template)
configurator = Configurator(
template="bobtemplates.plone:vocabulary",
diff --git a/requirements.txt b/requirements.txt
index 3eee9b3d..ccee098c 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,5 +1,6 @@
-cconstraints.txt
setuptools
+wheel
Sphinx
flake8
tox
diff --git a/setup.py b/setup.py
index 483a45e0..0444c661 100644
--- a/setup.py
+++ b/setup.py
@@ -63,6 +63,8 @@
"tox",
"isort",
"black",
+ # TODO: move from here, this is a mr.bob requiremnt
+ "pyreadline3",
],
setup_requires=[],
tests_require=[],
diff --git a/skeleton-tests/base.py b/skeleton-tests/base.py
index d89d4fc6..a83072c3 100644
--- a/skeleton-tests/base.py
+++ b/skeleton-tests/base.py
@@ -22,8 +22,8 @@ def generate_answers_ini(path, template):
f.write(template)
-def file_exists(base_path, file_path):
- is_file = os.path.isfile(base_path + file_path)
+def file_exists(base_path, *parts):
+ is_file = os.path.isfile(os.path.join(base_path, *parts))
return is_file
diff --git a/skeleton-tests/test_addon.py b/skeleton-tests/test_addon.py
index c509ad4e..f85fa2d9 100644
--- a/skeleton-tests/test_addon.py
+++ b/skeleton-tests/test_addon.py
@@ -4,7 +4,6 @@
from base import generate_answers_ini
from base import run_skeleton_tox_env
-import glob
import os.path
import subprocess
@@ -17,9 +16,9 @@
]
-addon_files = [
- "src/__init__.py",
-]
+# addon_files = [
+# os.path.join("src", "__init__.py"),
+# ]
def test_addon(tmpdir, capsys, config):
@@ -56,17 +55,14 @@ def test_addon(tmpdir, capsys, config):
)
assert result == 0
- generated_files = glob.glob(
- tmpdir.strpath + "/" + config.package_name + "/*",
- )
- length = len(tmpdir.strpath + "/" + config.package_name + "/")
- generated_files = [f[length:] for f in generated_files]
- required_files = base_files + addon_files
- assert required_files <= generated_files
+ generated_files = os.listdir(os.path.join(tmpdir.strpath, config.package_name))
+ # required_files = base_files + addon_files
+ required_files = base_files
+ assert set(required_files) <= set(generated_files)
- base_path = tmpdir.strpath + "/" + config.package_name
+ base_path = os.path.join(tmpdir.strpath, config.package_name)
- assert file_exists(base_path, "/src/collective/task/configure.zcml")
+ assert file_exists(base_path, "src", "collective", "task", "configure.zcml")
wd = os.path.abspath(
os.path.join(tmpdir.strpath, config.package_name),
diff --git a/skeleton-tests/test_addon_all.py b/skeleton-tests/test_addon_all.py
index 76b51921..5ed87055 100644
--- a/skeleton-tests/test_addon_all.py
+++ b/skeleton-tests/test_addon_all.py
@@ -98,7 +98,7 @@ def test_addon_all(tmpdir, capsys, config):
)
assert result == 0
- assert file_exists(wd, "/src/collective/task/configure.zcml")
+ assert file_exists(wd, "src", "collective", "task", "configure.zcml")
# generate subtemplate behavior:
template = """[variables]
@@ -120,10 +120,8 @@ def test_addon_all(tmpdir, capsys, config):
)
assert result == 0
- assert file_exists(wd, "/src/collective/task/behaviors/configure.zcml")
- assert file_exists(
- wd, "/src/collective/task/behaviors/project.py"
- ) # NOQA: S101,E501
+ assert file_exists(wd, "src", "collective", "task", "behaviors", "configure.zcml")
+ assert file_exists(wd, "src", "collective", "task", "behaviors", "project.py")
# generate subtemplate indexer:
template = """[variables]
@@ -145,9 +143,13 @@ def test_addon_all(tmpdir, capsys, config):
)
assert result == 0
- assert file_exists(wd, "/src/collective/task/indexers/configure.zcml")
- assert file_exists(wd, "/src/collective/task/indexers/my_custom_test_indexer.zcml")
- assert file_exists(wd, "/src/collective/task/indexers/my_custom_test_indexer.py")
+ assert file_exists(wd, "src", "collective", "task", "indexers", "configure.zcml")
+ assert file_exists(
+ wd, "src", "collective", "task", "indexers", "my_custom_test_indexer.zcml"
+ )
+ assert file_exists(
+ wd, "src", "collective", "task", "indexers", "my_custom_test_indexer.py"
+ )
# generate subtemplate portlet:
template = """[variables]
@@ -189,7 +191,7 @@ def test_addon_all(tmpdir, capsys, config):
)
assert result == 0
- assert file_exists(wd, "/src/collective/task/configure.zcml")
+ assert file_exists(wd, "src", "collective", "task", "configure.zcml")
# generate subtemplate restapi_service:
template = """[variables]
@@ -212,7 +214,7 @@ def test_addon_all(tmpdir, capsys, config):
)
assert result == 0
- assert file_exists(wd, "/src/collective/task/configure.zcml")
+ assert file_exists(wd, "src", "collective", "task", "configure.zcml")
# generate subtemplate svelte_app:
template = """[variables]
@@ -235,9 +237,15 @@ def test_addon_all(tmpdir, capsys, config):
)
assert result == 0
- assert file_exists(wd, "/svelte_src/my-custom-svelte-element/README.md")
+ assert file_exists(wd, "svelte_src", "my-custom-svelte-element", "README.md")
assert file_exists(
- wd, "/src/collective/task/svelte_apps/my-custom-svelte-element/README.md"
+ wd,
+ "src",
+ "collective",
+ "task",
+ "svelte_apps",
+ "my-custom-svelte-element",
+ "README.md",
)
# generate subtemplate upgrade_step:
@@ -261,9 +269,9 @@ def test_addon_all(tmpdir, capsys, config):
)
assert result == 0
- assert file_exists(wd, "/src/collective/task/upgrades/configure.zcml")
- assert file_exists(wd, "/src/collective/task/upgrades/1001.zcml")
- assert file_exists(wd, "/src/collective/task/upgrades/v1001.py")
+ assert file_exists(wd, "src", "collective", "task", "upgrades", "configure.zcml")
+ assert file_exists(wd, "src", "collective", "task", "upgrades", "1001.zcml")
+ assert file_exists(wd, "src", "collective", "task", "upgrades", "v1001.py")
# generate subtemplate view:
template = """[variables]
@@ -290,7 +298,7 @@ def test_addon_all(tmpdir, capsys, config):
)
assert result == 0
- assert file_exists(wd, "/src/collective/task/views/configure.zcml")
+ assert file_exists(wd, "src", "collective", "task", "views", "configure.zcml")
# generate subtemplate form:
template = """[variables]
@@ -314,7 +322,7 @@ def test_addon_all(tmpdir, capsys, config):
)
assert result == 0
- assert file_exists(wd, "/src/collective/task/forms/configure.zcml")
+ assert file_exists(wd, "src", "collective", "task", "forms", "configure.zcml")
# generate subtemplate viewlet:
template = """[variables]
@@ -338,7 +346,7 @@ def test_addon_all(tmpdir, capsys, config):
cwd=wd,
)
assert result == 0
- assert file_exists(wd, "/src/collective/task/viewlets/configure.zcml")
+ assert file_exists(wd, "src", "collective", "task", "viewlets", "configure.zcml")
# generate subtemplate viewlet:
template = """[variables]
@@ -362,7 +370,7 @@ def test_addon_all(tmpdir, capsys, config):
)
assert result == 0
- assert file_exists(wd, "/src/collective/task/viewlets/configure.zcml")
+ assert file_exists(wd, "src", "collective", "task", "viewlets", "configure.zcml")
# generate subtemplate vocabulary:
template = """[variables]
@@ -384,14 +392,14 @@ def test_addon_all(tmpdir, capsys, config):
)
assert result == 0
- assert file_exists(wd, "/src/collective/task/vocabularies/configure.zcml")
assert file_exists(
- wd,
- "/src/collective/task/tests/test_vocab_available_tasks.py",
+ wd, "src", "collective", "task", "vocabularies", "configure.zcml"
)
assert file_exists(
- wd,
- "/src/collective/task/vocabularies/available_tasks.py",
+ wd, "src", "collective", "task", "tests", "test_vocab_available_tasks.py"
+ )
+ assert file_exists(
+ wd, "src", "collective", "task", "vocabularies", "available_tasks.py"
)
with capsys.disabled():
diff --git a/skeleton-tests/test_addon_mockup_pattern.py b/skeleton-tests/test_addon_mockup_pattern.py
index de08ae25..1a067780 100644
--- a/skeleton-tests/test_addon_mockup_pattern.py
+++ b/skeleton-tests/test_addon_mockup_pattern.py
@@ -63,15 +63,31 @@ def test_addon_pattern(tmpdir, capsys, config):
],
)
- assert file_exists(wd, "/package.json")
- assert file_exists(wd, "/webpack.config.js")
+ assert file_exists(wd, "package.json")
+ assert file_exists(wd, "webpack.config.js")
assert file_exists(
wd,
- "/src/collective/testpattern/profiles/default/registry/bundles.xml",
+ "src",
+ "collective",
+ "testpattern",
+ "profiles",
+ "default",
+ "registry",
+ "bundles.xml",
)
found_jscompilation = False
with open(
- f"{wd}/src/collective/testpattern/profiles/default/registry/bundles.xml", "r"
+ os.path.join(
+ wd,
+ "src",
+ "collective",
+ "testpattern",
+ "profiles",
+ "default",
+ "registry",
+ "bundles.xml",
+ ),
+ "r",
) as bundles_file:
for line in bundles_file.readlines():
if "jscompilation" in line:
diff --git a/skeleton-tests/test_addon_theme_barceloneta.py b/skeleton-tests/test_addon_theme_barceloneta.py
index 7c1d435d..14380522 100644
--- a/skeleton-tests/test_addon_theme_barceloneta.py
+++ b/skeleton-tests/test_addon_theme_barceloneta.py
@@ -65,7 +65,7 @@ def test_addon_theme(tmpdir, capsys, config):
)
assert result == 0
- assert file_exists(wd, "/src/plonetheme/task/theme/manifest.cfg")
+ assert file_exists(wd, "src", "plonetheme", "task", "theme", "manifest.cfg")
with capsys.disabled():
run_skeleton_tox_env(wd, config)
@@ -127,4 +127,4 @@ def test_addon_theme_barceloneta_nested(tmpdir, capsys, config):
cwd=wd,
)
assert result == 0
- assert file_exists(wd, "/src/plonetheme/task/theme/manifest.cfg")
+ assert file_exists(wd, "src", "plonetheme", "task", "theme", "manifest.cfg")
diff --git a/tox.ini b/tox.ini
index 21ae3707..731d9bf0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -23,7 +23,7 @@ python =
3.10: py310
[testenv]
-usedevelop = True
+usedevelop = true
extras =
test
@@ -33,14 +33,15 @@ basepython:
py310: python3.10
commands =
- mkdir -p {toxinidir}/_build/reports/coverage {toxinidir}/_build/reports/pytest
- packagetests: pytest --cov=bobtemplates.plone --cov-config=setup.cfg --cov-report=xml --html={toxinidir}/_build/reports/pytest/report-{envname}.html --self-contained-html package_tests {posargs}
- template-addon: pytest skeleton-tests/test_addon.py {posargs}
- template-addon_all: pytest skeleton-tests/test_addon_all.py {posargs}
- template-addon_theme_barceoneta: pytest skeleton-tests/test_addon_theme_barceloneta.py {posargs}
- template-addon_mockup_pattern: pytest skeleton-tests/test_addon_mockup_pattern.py {posargs}
+ mkdir -p {toxinidir}{/}_build{/}reports{/}coverage {toxinidir}{/}_build{/}reports{/}pytest
+ packagetests: python -X utf8 -m pytest --cov=bobtemplates.plone --cov-config=setup.cfg --cov-report=xml --html={toxinidir}{/}_build{/}reports{/}pytest{/}report-{envname}.html --self-contained-html package_tests {posargs}
+ template-addon: python -X utf8 -m pytest skeleton-tests{/}test_addon.py {posargs}
+ template-addon_all: python -X utf8 -m pytest skeleton-tests{/}test_addon_all.py {posargs}
+ template-addon_theme_barceoneta: python -X utf8 -m pytest skeleton-tests{/}test_addon_theme_barceloneta.py {posargs}
+ template-addon_mockup_pattern: python -X utf8 -m pytest skeleton-tests{/}test_addon_mockup_pattern.py {posargs}
setenv =
+ PYTHONDONTWRITEBYTECODE=1
COVERAGE_FILE=.coverage.{envname}
Plone52: VERSION=5.2-latest
Plone60: VERSION=6.0-latest
@@ -52,7 +53,7 @@ passenv =
deps =
-cconstraints.txt
- pdbpp
+# pdbpp
pytest
pytest-cov
# pytest-remove-stale-bytecode
@@ -62,19 +63,14 @@ deps =
allowlist_externals =
mkdir
-depends =
- {py310}: coverage-clean
- coverage-report: py310
-
-
[testenv:coverage-report]
-#usedevelop = True
-basepython = python3.9
+usedevelop = true
+basepython = python3.10
deps =
-cconstraints.txt
coverage
depends =
- py{39}-packagetests,
+ py{310}-packagetests
#setenv =
# COVERAGE_FILE=.coverage
@@ -90,7 +86,8 @@ commands =
[testenv:coverage-clean]
deps = coverage
skip_install = true
-commands = coverage erase
+commands =
+ coverage erase
[testenv:isort-apply]
basepython = python3.10
@@ -102,7 +99,7 @@ commands =
isort {toxinidir}/bobtemplates setup.py skeleton-tests package_tests
[testenv:autopep8]
-basepython = python3.9
+basepython = python3.10
skip_install = true
deps =
-cconstraints.txt
@@ -138,10 +135,10 @@ deps =
; flake8_strict
commands =
- mkdir -p {toxinidir}/_build/reports/flake8
- isort --check-only {toxinidir}/bobtemplates {toxinidir}/package_tests {toxinidir}/skeleton-tests setup.py
- - flake8 --doctests {toxinidir}/bobtemplates {toxinidir}/package_tests {toxinidir}/skeleton-tests setup.py
- flake8 {toxinidir}/bobtemplates {toxinidir}/package_tests {toxinidir}/skeleton-tests setup.py --doctests
+ mkdir -p {toxinidir}{/}_build{/}reports{/}flake8
+ isort --check-only {toxinidir}{/}bobtemplates {toxinidir}{/}package_tests {toxinidir}{/}skeleton-tests setup.py
+ - flake8 --doctests {toxinidir}{/}bobtemplates {toxinidir}{/}package_tests {toxinidir}{/}skeleton-tests setup.py
+ flake8 {toxinidir}{/}bobtemplates {toxinidir}{/}package_tests {toxinidir}{/}skeleton-tests setup.py --doctests
allowlist_externals =
mkdir