From 0e1ca0addec742ac96c5d55b76f37abb65c1ef01 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Wed, 3 Aug 2022 10:11:46 +0200 Subject: [PATCH 01/15] run tests on windows and osx too --- .github/workflows/python-package.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index a767043c..72c9c05a 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -11,23 +11,28 @@ on: jobs: build: - runs-on: ubuntu-latest strategy: - fail-fast: false matrix: - python-version: [3.9, 3.8, 3.7] + python-version: + - "3.7" + - "3.8" + - "3.9" + os: + - ubuntu-latest + - windows-latest + - macos-latest + runs-on: ${{ matrix.os }} steps: - - uses: actions/setup-python@v2 - with: - python-version: '3.9' - uses: actions/checkout@v2 + - uses: actions/cache@v2 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 with: @@ -39,9 +44,11 @@ jobs: pip install flake8 tox tox-gh-actions if [ -f requirements.txt ]; then pip install -r requirements.txt; fi pip install -e . + - name: Black-Check run: | tox -r -e black-check + - name: Test with tox run: | tox -r From 55db9eb6224a65a4828acc2921bb9b4de7047f40 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Wed, 3 Aug 2022 10:16:13 +0200 Subject: [PATCH 02/15] no sh syntax --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 72c9c05a..53631605 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -42,7 +42,7 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 tox tox-gh-actions - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + pip install -r requirements.txt pip install -e . - name: Black-Check From 8974fa543a4c936ee3c3ec55476728844e034bcd Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Wed, 3 Aug 2022 10:23:44 +0200 Subject: [PATCH 03/15] no fail fast to see how the other OS do --- .github/workflows/python-package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 53631605..0d335258 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -12,6 +12,7 @@ on: jobs: build: strategy: + fail-fast: false matrix: python-version: - "3.7" From 499a18088473beb9c647728314ed1f6bc24875d0 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Tue, 24 Jan 2023 11:26:26 +0100 Subject: [PATCH 04/15] remove 3.7 from ci --- .github/workflows/python-package.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 43010d84..ac63dccd 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -15,7 +15,6 @@ jobs: fail-fast: true matrix: python-version: - - "3.7" - "3.8" - "3.9" - "3.10" From 9d29839bfdea839508c737cc02c9452d522c1a6d Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Tue, 24 Jan 2023 11:29:07 +0100 Subject: [PATCH 05/15] windows compat --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index ac63dccd..0f62bbfd 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -42,7 +42,7 @@ jobs: - 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 . From 162ea6a76d7b79730cd9b97f3ec3e87900c0c5ac Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Wed, 25 Jan 2023 17:40:45 +0100 Subject: [PATCH 06/15] ci: run on windows powershell --- .github/workflows/python-package.yml | 4 +++- .gitignore | 1 + tox.ini | 17 ++++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 0f62bbfd..2001ca45 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -23,7 +23,9 @@ jobs: - windows-latest - macos-latest runs-on: ${{ matrix.os }} - + env: + PYTHONIOENCODING: "utf-8" + PYTHONLEGACYWINDOWSSTDIO: "utf-8" steps: - uses: actions/checkout@v3 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/tox.ini b/tox.ini index 21ae3707..ee15c45f 100644 --- a/tox.ini +++ b/tox.ini @@ -14,6 +14,10 @@ envlist = py{38,39,310}-skeletontests-Plone{60}-template-addon_mockup_pattern coverage-report +platform = lin: linux + mac: darwin + win: win32 + skip_missing_interpreters = True [gh-actions] @@ -33,12 +37,14 @@ basepython: py310: python3.10 commands = - mkdir -p {toxinidir}/_build/reports/coverage {toxinidir}/_build/reports/pytest + lin: mkdir -p {toxinidir}/_build/reports/coverage {toxinidir}/_build/reports/pytest + mac: mkdir -p {toxinidir}/_build/reports/coverage {toxinidir}/_build/reports/pytest + win: mkdir {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} + 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} setenv = COVERAGE_FILE=.coverage.{envname} @@ -58,6 +64,7 @@ deps = # pytest-remove-stale-bytecode pytest-mock pytest-html + pyreadline3 allowlist_externals = mkdir From 6e735a496971eda2cf857a8358c259b215323cd0 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Thu, 26 Jan 2023 17:27:55 +0100 Subject: [PATCH 07/15] ci: windows (wip) --- .github/workflows/python-package.yml | 3 ++- bobtemplates/plone/base.py | 6 ++++-- bobtemplates/plone/behavior.py | 6 ++++-- bobtemplates/plone/content_type.py | 29 ++++++++++++++------------ bobtemplates/plone/controlpanel.py | 6 ++++-- bobtemplates/plone/portlet.py | 10 +++++---- constraints.txt | 1 + package_tests/test_behavior.py | 14 ++++++------- package_tests/test_theme.py | 4 ++-- requirements.txt | 1 + setup.py | 2 ++ tox.ini | 31 +++++++++++++++++----------- 12 files changed, 68 insertions(+), 45 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 2001ca45..f0d5d830 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -46,7 +46,6 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt pip install tox-gh-actions>=3.0.0 - pip install -e . - name: Black-Check run: | @@ -55,3 +54,5 @@ jobs: - name: Test with tox run: | tox -r + env: + PLATFORM: ${{ matrix.os }} diff --git a/bobtemplates/plone/base.py b/bobtemplates/plone/base.py index d3afd119..92ef30a0 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 @@ -447,7 +447,9 @@ 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_rel_path"] = os.path.join( + "", "src", package_subpath + ) configurator.variables["package_folder"] = ( configurator.variables["package.root_folder"] + configurator.variables["package_folder_rel_path"] 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..05e8489f 100644 --- a/bobtemplates/plone/content_type.py +++ b/bobtemplates/plone/content_type.py @@ -61,12 +61,10 @@ 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"], + metadata_file_dir, + 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.jon(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..67fd2a46 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) @@ -36,7 +36,9 @@ def _update_package_configure_zcml(configurator): def _update_controlpanels_configure_zcml(configurator): file_name = "configure.zcml" - file_path = configurator.variables["package_folder"] + "/controlpanels/" + file_name + file_path = os.path.join( + configurator.variables["package_folder"], "controlpanels", 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/portlet.py b/bobtemplates/plone/portlet.py index 36626186..25995f56 100644 --- a/bobtemplates/plone/portlet.py +++ b/bobtemplates/plone/portlet.py @@ -19,10 +19,12 @@ 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)) if file_name not in file_list: diff --git a/constraints.txt b/constraints.txt index d7bffc21..d534a76b 100644 --- a/constraints.txt +++ b/constraints.txt @@ -2,6 +2,7 @@ # ----------------------------------------------- # Pin Versions / Version Ranges if necessary. setuptools==57.0.0 +wheel==0.38.4 tox==4.3.5 isort>=5 flake8==5.0.4 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_theme.py b/package_tests/test_theme.py index cd98038c..9b52fe3a 100644 --- a/package_tests/test_theme.py +++ b/package_tests/test_theme.py @@ -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,7 +81,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.foo.bar/src/collective/foo/bar" + os.path.join("", "collective.foo.bar", "src", "collective", "foo", "bar") ) # NOQA: E501 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/tox.ini b/tox.ini index ee15c45f..7b5e924a 100644 --- a/tox.ini +++ b/tox.ini @@ -14,9 +14,9 @@ envlist = py{38,39,310}-skeletontests-Plone{60}-template-addon_mockup_pattern coverage-report -platform = lin: linux - mac: darwin - win: win32 +platform = linux: linux + macos: darwin + windows: win32 skip_missing_interpreters = True @@ -26,6 +26,12 @@ python = 3.9: py39 3.10: py310 +[gh-actions:env] +PLATFORM = + ubuntu-latest: linux + macos-latest: macos + windows-latest: windows + [testenv] usedevelop = True extras = @@ -37,9 +43,9 @@ basepython: py310: python3.10 commands = - lin: mkdir -p {toxinidir}/_build/reports/coverage {toxinidir}/_build/reports/pytest - mac: mkdir -p {toxinidir}/_build/reports/coverage {toxinidir}/_build/reports/pytest - win: mkdir {toxinidir}\_build\reports\coverage {toxinidir}\_build\reports\pytest + linux: mkdir -p {toxinidir}/_build/reports/coverage {toxinidir}/_build/reports/pytest + macos: mkdir -p {toxinidir}/_build/reports/coverage {toxinidir}/_build/reports/pytest + windows: mkdir {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} @@ -58,13 +64,12 @@ passenv = deps = -cconstraints.txt - pdbpp +# pdbpp pytest pytest-cov # pytest-remove-stale-bytecode pytest-mock pytest-html - pyreadline3 allowlist_externals = mkdir @@ -76,12 +81,12 @@ depends = [testenv:coverage-report] #usedevelop = True -basepython = python3.9 +basepython = python3.10 deps = -cconstraints.txt coverage depends = - py{39}-packagetests, + py{310}-packagetests, #setenv = # COVERAGE_FILE=.coverage @@ -109,7 +114,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 @@ -145,7 +150,9 @@ deps = ; flake8_strict commands = - mkdir -p {toxinidir}/_build/reports/flake8 + linux: mkdir -p {toxinidir}/_build/reports/flake8 + macos: mkdir -p {toxinidir}/_build/reports/flake8 + windows: mkdir {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 From b92762d642f8dbcf6433bec070c7c031df955b84 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Thu, 26 Jan 2023 17:43:51 +0100 Subject: [PATCH 08/15] ci: platform --- tox.ini | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tox.ini b/tox.ini index 7b5e924a..336c8617 100644 --- a/tox.ini +++ b/tox.ini @@ -1,17 +1,17 @@ [tox] envlist = - py38-lint - py39-lint - py310-lint - black-check + py38-lint-{linux,macos,windows} + py39-lint-{linux,macos,windows} + py310-lint-{linux,macos,windows} + black-check-{linux,macos,windows} docs - py{310,39,38}-packagetests - py{38}-skeletontests-Plone{52}-template-addon - py{310,39}-skeletontests-Plone{60}-template-addon - py{38}-skeletontests-Plone{52}-template-addon_all - py{310,39}-skeletontests-Plone{60}-template-addon_all - py{310,39}-skeletontests-Plone{60}-template-addon_theme_barceoneta - py{38,39,310}-skeletontests-Plone{60}-template-addon_mockup_pattern + py{310,39,38}-packagetests-{linux,macos,windows} + py{38}-skeletontests-Plone{52}-template-addon-{linux,macos,windows} + py{310,39}-skeletontests-Plone{60}-template-addon-{linux,macos,windows} + py{38}-skeletontests-Plone{52}-template-addon_all-{linux,macos,windows} + py{310,39}-skeletontests-Plone{60}-template-addon_all-{linux,macos,windows} + py{310,39}-skeletontests-Plone{60}-template-addon_theme_barceoneta-{linux,macos,windows} + py{38,39,310}-skeletontests-Plone{60}-template-addon_mockup_pattern-{linux,macos,windows} coverage-report platform = linux: linux From dea07b75bace4ab0baea7b0680d8da68b5a0f943 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Thu, 26 Jan 2023 17:50:58 +0100 Subject: [PATCH 09/15] ci: windows mkdir --- tox.ini | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tox.ini b/tox.ini index 336c8617..55f979cc 100644 --- a/tox.ini +++ b/tox.ini @@ -43,10 +43,8 @@ basepython: py310: python3.10 commands = - linux: mkdir -p {toxinidir}/_build/reports/coverage {toxinidir}/_build/reports/pytest - macos: mkdir -p {toxinidir}/_build/reports/coverage {toxinidir}/_build/reports/pytest - windows: mkdir {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} + 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} @@ -150,12 +148,10 @@ deps = ; flake8_strict commands = - linux: mkdir -p {toxinidir}/_build/reports/flake8 - macos: mkdir -p {toxinidir}/_build/reports/flake8 - windows: mkdir {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 From 77f968d25fbc3ffc29cc7369d2d938e8689b2f41 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Sun, 29 Jan 2023 01:16:33 +0100 Subject: [PATCH 10/15] fix: multi os --- bobtemplates/plone/addon.py | 8 +-- bobtemplates/plone/addon/tox.ini | 29 ++++----- bobtemplates/plone/base.py | 12 ++-- bobtemplates/plone/content_type.py | 6 +- bobtemplates/plone/controlpanel.py | 17 ++++-- bobtemplates/plone/form.py | 19 +++--- bobtemplates/plone/indexer.py | 8 ++- bobtemplates/plone/mockup_pattern.py | 2 +- bobtemplates/plone/portlet.py | 36 ++++++------ bobtemplates/plone/restapi_service.py | 18 +++--- bobtemplates/plone/svelte_app.py | 3 +- bobtemplates/plone/theme.py | 14 ++--- bobtemplates/plone/theme_barceloneta.py | 14 ++--- bobtemplates/plone/theme_basic.py | 12 ++-- bobtemplates/plone/upgrade_step.py | 12 ++-- bobtemplates/plone/view.py | 24 ++++---- bobtemplates/plone/viewlet.py | 20 +++---- bobtemplates/plone/vocabulary.py | 10 +++- package_tests/base.py | 15 +++-- package_tests/test_addon.py | 26 ++++----- package_tests/test_base.py | 38 ++++++------ package_tests/test_content_type.py | 56 +++++++++--------- package_tests/test_form.py | 20 +++---- package_tests/test_indexer.py | 16 ++--- package_tests/test_mockup_pattern.py | 14 +++-- package_tests/test_portlet.py | 78 ++++++++++++------------- package_tests/test_restapi_service.py | 70 +++++++++++----------- package_tests/test_subscriber.py | 10 ++-- package_tests/test_svelte_app.py | 4 +- package_tests/test_theme_barceloneta.py | 6 +- package_tests/test_theme_basic.py | 6 +- package_tests/test_upgrade_step.py | 20 +++---- package_tests/test_view.py | 58 +++++++++--------- package_tests/test_viewlet.py | 8 +-- tox.ini | 32 ++++------ 35 files changed, 370 insertions(+), 371 deletions(-) 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 92ef30a0..c5938f1f 100644 --- a/bobtemplates/plone/base.py +++ b/bobtemplates/plone/base.py @@ -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 @@ -450,9 +448,9 @@ def base_prepare_renderer(configurator): configurator.variables["package_folder_rel_path"] = os.path.join( "", "src", package_subpath ) - configurator.variables["package_folder"] = ( - configurator.variables["package.root_folder"] - + configurator.variables["package_folder_rel_path"] + 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/content_type.py b/bobtemplates/plone/content_type.py index 05e8489f..0f3f3cbe 100644 --- a/bobtemplates/plone/content_type.py +++ b/bobtemplates/plone/content_type.py @@ -60,10 +60,10 @@ 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 = os.path.join( configurator.variables["package_folder"], - metadata_file_dir, + "profiles", + "default", metadata_file_name, ) @@ -227,7 +227,7 @@ def _update_rolemap_xml(configurator): def _update_permissions_zcml(configurator): file_name = "permissions.zcml" - file_path = os.path.jon(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 67fd2a46..de9009d4 100644 --- a/bobtemplates/plone/controlpanel.py +++ b/bobtemplates/plone/controlpanel.py @@ -35,12 +35,14 @@ def _update_package_configure_zcml(configurator): def _update_controlpanels_configure_zcml(configurator): - file_name = "configure.zcml" - file_path = os.path.join( - configurator.variables["package_folder"], "controlpanels", file_name + directory_path = os.path.join( + configurator.variables["package_folder"], + "controlpanels", ) + file_name = "configure.zcml" + 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) @@ -74,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 25995f56..b3c1ef20 100644 --- a/bobtemplates/plone/portlet.py +++ b/bobtemplates/plone/portlet.py @@ -26,7 +26,7 @@ def _update_portlets_configure_zcml(configurator): "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) @@ -72,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) @@ -134,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/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..540b8fd9 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,7 @@ 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 +150,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 +167,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 +251,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 +314,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_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..5cb452db 100644 --- a/package_tests/test_mockup_pattern.py +++ b/package_tests/test_mockup_pattern.py @@ -7,10 +7,12 @@ 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 +29,9 @@ 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 +56,14 @@ 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" + import pdb; pdb.set_trace() + 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..4a68c79a 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,7 @@ 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, ), "w", ) as f: @@ -133,28 +133,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), ) 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 +168,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 +189,7 @@ 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 +199,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 +228,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 +255,7 @@ 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..37bce538 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 ) 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..8b30a244 100644 --- a/package_tests/test_upgrade_step.py +++ b/package_tests/test_upgrade_step.py @@ -9,7 +9,7 @@ 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") @@ -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,7 +137,7 @@ 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") diff --git a/package_tests/test_view.py b/package_tests/test_view.py index d3d99c67..37c74446 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..cc1f80d5 100644 --- a/package_tests/test_viewlet.py +++ b/package_tests/test_viewlet.py @@ -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) @@ -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) diff --git a/tox.ini b/tox.ini index 55f979cc..28c48d14 100644 --- a/tox.ini +++ b/tox.ini @@ -1,23 +1,19 @@ [tox] envlist = - py38-lint-{linux,macos,windows} - py39-lint-{linux,macos,windows} - py310-lint-{linux,macos,windows} - black-check-{linux,macos,windows} + py38-lint + py39-lint + py310-lint + black-check docs - py{310,39,38}-packagetests-{linux,macos,windows} - py{38}-skeletontests-Plone{52}-template-addon-{linux,macos,windows} - py{310,39}-skeletontests-Plone{60}-template-addon-{linux,macos,windows} - py{38}-skeletontests-Plone{52}-template-addon_all-{linux,macos,windows} - py{310,39}-skeletontests-Plone{60}-template-addon_all-{linux,macos,windows} - py{310,39}-skeletontests-Plone{60}-template-addon_theme_barceoneta-{linux,macos,windows} - py{38,39,310}-skeletontests-Plone{60}-template-addon_mockup_pattern-{linux,macos,windows} + py{310,39,38}-packagetests + py{38}-skeletontests-Plone{52}-template-addon + py{310,39}-skeletontests-Plone{60}-template-addon + py{38}-skeletontests-Plone{52}-template-addon_all + py{310,39}-skeletontests-Plone{60}-template-addon_all + py{310,39}-skeletontests-Plone{60}-template-addon_theme_barceoneta + py{38,39,310}-skeletontests-Plone{60}-template-addon_mockup_pattern coverage-report -platform = linux: linux - macos: darwin - windows: win32 - skip_missing_interpreters = True [gh-actions] @@ -26,12 +22,6 @@ python = 3.9: py39 3.10: py310 -[gh-actions:env] -PLATFORM = - ubuntu-latest: linux - macos-latest: macos - windows-latest: windows - [testenv] usedevelop = True extras = From 2caa37653aebe6cae18bac4a3af03c62799c8dce Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Sun, 29 Jan 2023 01:20:24 +0100 Subject: [PATCH 11/15] fix: black --- package_tests/test_base.py | 4 +++- package_tests/test_mockup_pattern.py | 18 +++++++++++++----- package_tests/test_restapi_service.py | 11 ++++++++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/package_tests/test_base.py b/package_tests/test_base.py index 540b8fd9..00d96acb 100644 --- a/package_tests/test_base.py +++ b/package_tests/test_base.py @@ -138,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) == os.path.join("collective", "todo", "content") + assert base.dottedname_to_path(dottedname) == os.path.join( + "collective", "todo", "content" + ) def test_subtemplate_warning(capsys): diff --git a/package_tests/test_mockup_pattern.py b/package_tests/test_mockup_pattern.py index 5cb452db..316a663c 100644 --- a/package_tests/test_mockup_pattern.py +++ b/package_tests/test_mockup_pattern.py @@ -10,7 +10,9 @@ import sys -@pytest.mark.skipif(sys.platform == "win32", reason="needs to fix mr.bob to run on windows") +@pytest.mark.skipif( + sys.platform == "win32", reason="needs to fix mr.bob to run on windows" +) def test_pre_render(tmpdir): package_root = os.path.join(tmpdir.strpath, "collective.testpattern") package_path = init_package_base_structure(package_root) @@ -29,7 +31,9 @@ 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") +@pytest.mark.skipif( + sys.platform == "win32", reason="needs to fix mr.bob to run on windows" +) def test_post_render(tmpdir): package_root = os.path.join(tmpdir.strpath, "collective.testpattern") package_path = init_package_base_structure(package_root) @@ -56,13 +60,17 @@ 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") +@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.""" - import pdb; pdb.set_trace() + import pdb + + pdb.set_trace() target_path = os.path.join(tmpdir.strpath, "collective.testpattern") configurator = Configurator( - template="bobtemplates.plone:mockup_pattern", + template="bobtemplates.plone:mockup_pattern", target_directory=target_path, ) diff --git a/package_tests/test_restapi_service.py b/package_tests/test_restapi_service.py index 4a68c79a..45c8ac99 100644 --- a/package_tests/test_restapi_service.py +++ b/package_tests/test_restapi_service.py @@ -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, ), "w", ) as f: @@ -189,7 +190,8 @@ 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: @@ -255,7 +257,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: From 7e2c3c286f402bdd5c2008b98e340f5472239e5e Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Sun, 29 Jan 2023 01:31:43 +0100 Subject: [PATCH 12/15] remove pdb --- package_tests/test_mockup_pattern.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/package_tests/test_mockup_pattern.py b/package_tests/test_mockup_pattern.py index 316a663c..f776978d 100644 --- a/package_tests/test_mockup_pattern.py +++ b/package_tests/test_mockup_pattern.py @@ -65,9 +65,6 @@ def test_post_render(tmpdir): ) def test_post_pattern_name(tmpdir): """Verifies that pattern names are checked for validity.""" - import pdb - - pdb.set_trace() target_path = os.path.join(tmpdir.strpath, "collective.testpattern") configurator = Configurator( template="bobtemplates.plone:mockup_pattern", From 37d4ed41be5335ec737d134e1291e559d2423698 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Sun, 29 Jan 2023 01:45:49 +0100 Subject: [PATCH 13/15] disable macos --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index f0d5d830..75b51a09 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -21,7 +21,7 @@ jobs: os: - ubuntu-latest - windows-latest - - macos-latest + # - macos-latest runs-on: ${{ matrix.os }} env: PYTHONIOENCODING: "utf-8" From d438b6442d14b286cba6c4c88a8150384ff71003 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Tue, 7 Feb 2023 11:21:03 +0100 Subject: [PATCH 14/15] ci: windows encoding error --- constraints.txt | 2 +- tox.ini | 27 ++++++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/constraints.txt b/constraints.txt index d534a76b..6c2945ce 100644 --- a/constraints.txt +++ b/constraints.txt @@ -3,7 +3,7 @@ # Pin Versions / Version Ranges if necessary. setuptools==57.0.0 wheel==0.38.4 -tox==4.3.5 +tox==4.4.4 isort>=5 flake8==5.0.4 flake8-html==0.4.2 diff --git a/tox.ini b/tox.ini index 28c48d14..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 @@ -62,19 +63,14 @@ deps = allowlist_externals = mkdir -depends = - {py310}: coverage-clean - coverage-report: py310 - - [testenv:coverage-report] -#usedevelop = True +usedevelop = true basepython = python3.10 deps = -cconstraints.txt coverage depends = - py{310}-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 From b127c8601bc3f6207ea65f81611e86cc455913e1 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Tue, 7 Feb 2023 13:09:45 +0100 Subject: [PATCH 15/15] ci: path join --- package_tests/test_restapi_service.py | 9 ++- package_tests/test_svelte_app.py | 14 ++-- package_tests/test_theme.py | 4 +- package_tests/test_upgrade_step.py | 4 +- package_tests/test_view.py | 2 +- package_tests/test_viewlet.py | 76 +++++++++---------- package_tests/test_vocabulary.py | 14 ++-- skeleton-tests/base.py | 4 +- skeleton-tests/test_addon.py | 22 +++--- skeleton-tests/test_addon_all.py | 56 ++++++++------ skeleton-tests/test_addon_mockup_pattern.py | 24 +++++- .../test_addon_theme_barceloneta.py | 4 +- 12 files changed, 125 insertions(+), 108 deletions(-) diff --git a/package_tests/test_restapi_service.py b/package_tests/test_restapi_service.py index 45c8ac99..21dfa4a4 100644 --- a/package_tests/test_restapi_service.py +++ b/package_tests/test_restapi_service.py @@ -125,7 +125,7 @@ def test_remove_unwanted_files(tmpdir): with open( os.path.join( package_path, - file_to_remove, + *file_to_remove.split("/"), ), "w", ) as f: @@ -134,7 +134,7 @@ 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("/")), ) @@ -171,7 +171,7 @@ def test_update_api_configure_zcml(tmpdir): """ 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", @@ -191,7 +191,8 @@ def test_update_api_configure_zcml(tmpdir): with open( os.path.join( package_path, - "api/configure.zcml", + "api", + "configure.zcml", ), "r", ) as f: diff --git a/package_tests/test_svelte_app.py b/package_tests/test_svelte_app.py index 37bce538..c5e4e654 100644 --- a/package_tests/test_svelte_app.py +++ b/package_tests/test_svelte_app.py @@ -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 9b52fe3a..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( @@ -86,7 +86,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 8b30a244..ecca8e2f 100644 --- a/package_tests/test_upgrade_step.py +++ b/package_tests/test_upgrade_step.py @@ -11,7 +11,7 @@ def test_pre_renderer(tmpdir): 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 = """ @@ -139,7 +139,7 @@ def test_read_source_version(tmpdir): def test_write_dest_version(tmpdir): 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 37c74446..52fc137a 100644 --- a/package_tests/test_view.py +++ b/package_tests/test_view.py @@ -95,7 +95,7 @@ def test_update_views_configure_zcml(tmpdir): """Test configure changes when changes are already in place.""" 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/") + views_path = os.path.join(package_path, "views") os.makedirs(target_path) os.makedirs(package_path) os.makedirs(views_path) diff --git a/package_tests/test_viewlet.py b/package_tests/test_viewlet.py index cc1f80d5..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) @@ -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) @@ -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/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")