Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rnixx committed Jan 22, 2024
1 parent 900d799 commit 3d27641
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 106 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
- name: Install Dependencies
run: make install

- name: black
run: make black
- name: ruff
run: make ruff-check

- name: isort
run: make isort-check
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
__pycache__
*.egg-info
*.pyc
/.coverage
/.mxmake/
/.mypy_cache/
/.pytest_cache/
/.ruff_cache/
/.vscode/
/build/
/constraints-mxdev.txt
/dist/
/docs/html/
/requirements-mxdev.txt
/venv/
__pycache__
15 changes: 8 additions & 7 deletions src/mxmake/tests/test_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@
import io
import mxdev
import os
import pathlib
import unittest


class TestHook(unittest.TestCase):
@testing.template_directory()
def test_Hook(self, tempdir):
config_file = io.StringIO()
config_file.write(
"[settings]\n" "mxmake-templates = run-tests run-coverage inexistent"
)
config_file.seek(0)
mxini = pathlib.Path(tempdir, "mx.ini")
with mxini.open("w") as fd:
fd.write(
"[settings]\n" "mxmake-templates = run-tests run-coverage inexistent"
)

hook_ = hook.Hook()
configuration = mxdev.Configuration(config_file, hooks=[hook_])
configuration = mxdev.Configuration(mxini, hooks=[hook_])
state = mxdev.State(configuration=configuration)
hook_.write(state)
self.assertEqual(
sorted(os.listdir(tempdir)), ["run-coverage.sh", "run-tests.sh"]
sorted(os.listdir(tempdir)), ["mx.ini", "run-coverage.sh", "run-tests.sh"]
)
179 changes: 88 additions & 91 deletions src/mxmake/tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io
import mxdev
import os
import pathlib
import typing


Expand Down Expand Up @@ -116,22 +117,22 @@ class Template(templates.EnvironmentTemplate):

@testing.template_directory()
def test_TestScript(self, tempdir):
config_file = io.StringIO()
config_file.write(
"[settings]\n"
"mxmake-test-path = src\n"
"mxmake-test-runner = zope-testrunner\n"
"[mxmake-env]\n"
"ENV_PARAM = env_value\n"
"[mxmake-run-tests]\n"
"environment = env\n"
"[package]\n"
"url = https://github.com/org/package\n"
"mxmake-test-path = src\n"
)
config_file.seek(0)
mxini = pathlib.Path(tempdir, "mx.ini")
with mxini.open("w") as fd:
fd.write(
"[settings]\n"
"mxmake-test-path = src\n"
"mxmake-test-runner = zope-testrunner\n"
"[mxmake-env]\n"
"ENV_PARAM = env_value\n"
"[mxmake-run-tests]\n"
"environment = env\n"
"[package]\n"
"url = https://github.com/org/package\n"
"mxmake-test-path = src\n"
)

configuration = mxdev.Configuration(config_file, hooks=[hook.Hook()])
configuration = mxdev.Configuration(mxini, hooks=[hook.Hook()])
factory = templates.template.lookup("run-tests")
template = factory(configuration, templates.get_template_environment())

Expand Down Expand Up @@ -190,17 +191,16 @@ def test_TestScript(self, tempdir):
f.read(),
)

config_file = io.StringIO()
config_file.write(
"[settings]\n"
"mxmake-test-runner = zope-testrunner\n"
"[package]\n"
"url = https://github.com/org/package\n"
"mxmake-test-path = src\n"
)
config_file.seek(0)
with mxini.open("w") as fd:
fd.write(
"[settings]\n"
"mxmake-test-runner = zope-testrunner\n"
"[package]\n"
"url = https://github.com/org/package\n"
"mxmake-test-path = src\n"
)

configuration = mxdev.Configuration(config_file, hooks=[hook.Hook()])
configuration = mxdev.Configuration(mxini, hooks=[hook.Hook()])
template = factory(configuration, templates.get_template_environment())
template.write()
with open(os.path.join(tempdir, "run-tests.sh")) as f:
Expand All @@ -223,17 +223,16 @@ def test_TestScript(self, tempdir):
f.read(),
)

config_file = io.StringIO()
config_file.write(
"[settings]\n"
"mxmake-test-runner = pytest\n"
"[package]\n"
"url = https://github.com/org/package\n"
"mxmake-test-path = src\n"
)
config_file.seek(0)
with mxini.open("w") as fd:
fd.write(
"[settings]\n"
"mxmake-test-runner = pytest\n"
"[package]\n"
"url = https://github.com/org/package\n"
"mxmake-test-path = src\n"
)

configuration = mxdev.Configuration(config_file, hooks=[hook.Hook()])
configuration = mxdev.Configuration(mxini, hooks=[hook.Hook()])
template = factory(configuration, templates.get_template_environment())
template.write()
with open(os.path.join(tempdir, "run-tests.sh")) as f:
Expand All @@ -257,30 +256,30 @@ def test_TestScript(self, tempdir):

@testing.template_directory()
def test_CoverageScript(self, tempdir):
config_file = io.StringIO()
config_file.write(
"[settings]\n"
"mxmake-test-runner = zope-testrunner\n"
"mxmake-test-path = src\n"
"mxmake-source-path = src/local\n"
"mxmake-omit-path =\n"
" src/local/file1.py\n"
" src/local/file2.py\n"
"[mxmake-env]\n"
"ENV_PARAM = env_value\n"
"[mxmake-run-coverage]\n"
"environment = env\n"
"[package]\n"
"url = https://github.com/org/package\n"
"mxmake-test-path = src\n"
"mxmake-source-path = src/package\n"
"mxmake-omit-path =\n"
" src/package/file1.py\n"
" src/package/file2.py\n"
)
config_file.seek(0)
mxini = pathlib.Path(tempdir, "mx.ini")
with mxini.open("w") as fd:
fd.write(
"[settings]\n"
"mxmake-test-runner = zope-testrunner\n"
"mxmake-test-path = src\n"
"mxmake-source-path = src/local\n"
"mxmake-omit-path =\n"
" src/local/file1.py\n"
" src/local/file2.py\n"
"[mxmake-env]\n"
"ENV_PARAM = env_value\n"
"[mxmake-run-coverage]\n"
"environment = env\n"
"[package]\n"
"url = https://github.com/org/package\n"
"mxmake-test-path = src\n"
"mxmake-source-path = src/package\n"
"mxmake-omit-path =\n"
" src/package/file1.py\n"
" src/package/file2.py\n"
)

configuration = mxdev.Configuration(config_file, hooks=[hook.Hook()])
configuration = mxdev.Configuration(mxini, hooks=[hook.Hook()])
factory = templates.template.lookup("run-coverage")
template = factory(configuration, templates.get_template_environment())

Expand Down Expand Up @@ -382,18 +381,17 @@ def test_CoverageScript(self, tempdir):
f.read(),
)

config_file = io.StringIO()
config_file.write(
"[settings]\n"
"mxmake-test-runner = zope-testrunner\n"
"[package]\n"
"url = https://github.com/org/package\n"
"mxmake-test-path = src\n"
"mxmake-source-path = src/package\n"
)
config_file.seek(0)
with mxini.open("w") as fd:
fd.write(
"[settings]\n"
"mxmake-test-runner = zope-testrunner\n"
"[package]\n"
"url = https://github.com/org/package\n"
"mxmake-test-path = src\n"
"mxmake-source-path = src/package\n"
)

configuration = mxdev.Configuration(config_file, hooks=[hook.Hook()])
configuration = mxdev.Configuration(mxini, hooks=[hook.Hook()])
template = factory(configuration, templates.get_template_environment())
template.write()
with open(os.path.join(tempdir, "run-coverage.sh")) as f:
Expand Down Expand Up @@ -427,18 +425,17 @@ def test_CoverageScript(self, tempdir):
f.read(),
)

config_file = io.StringIO()
config_file.write(
"[settings]\n"
"mxmake-test-runner = pytest\n"
"[package]\n"
"url = https://github.com/org/package\n"
"mxmake-test-path = src\n"
"mxmake-source-path = src/package\n"
)
config_file.seek(0)
with mxini.open("w") as fd:
fd.write(
"[settings]\n"
"mxmake-test-runner = pytest\n"
"[package]\n"
"url = https://github.com/org/package\n"
"mxmake-test-path = src\n"
"mxmake-source-path = src/package\n"
)

configuration = mxdev.Configuration(config_file, hooks=[hook.Hook()])
configuration = mxdev.Configuration(mxini, hooks=[hook.Hook()])
template = factory(configuration, templates.get_template_environment())
template.write()
with open(os.path.join(tempdir, "run-coverage.sh")) as f:
Expand Down Expand Up @@ -474,18 +471,18 @@ def test_CoverageScript(self, tempdir):

@testing.template_directory()
def test_PipConf(self, tempdir):
config_file = io.StringIO()
config_file.write(
"[settings]\n"
"\n"
"[mxmake-pip-conf]\n"
"find-links =\n"
" file:///path/to/folder\n"
" https://tld.com/\n"
)
config_file.seek(0)
mxini = pathlib.Path(tempdir, "mx.ini")
with mxini.open("w") as fd:
fd.write(
"[settings]\n"
"\n"
"[mxmake-pip-conf]\n"
"find-links =\n"
" file:///path/to/folder\n"
" https://tld.com/\n"
)

configuration = mxdev.Configuration(config_file, hooks=[hook.Hook()])
configuration = mxdev.Configuration(mxini, hooks=[hook.Hook()])
factory = templates.template.lookup("pip-conf")
template = factory(configuration, templates.get_template_environment())

Expand Down
1 change: 0 additions & 1 deletion src/mxmake/topics/qa/black.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#:
#:[target.black-clean]
#:description = Uninstall black.
#:

##############################################################################
# black
Expand Down
1 change: 0 additions & 1 deletion src/mxmake/topics/qa/isort.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#:
#:[target.isort-clean]
#:description = Uninstall isort.
#:

##############################################################################
# isort
Expand Down
1 change: 0 additions & 1 deletion src/mxmake/topics/qa/mypy.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#:
#:[target.mypy-clean]
#:description = Uninstall mypy and removes cached data.
#:

##############################################################################
# mypy
Expand Down
1 change: 0 additions & 1 deletion src/mxmake/topics/qa/ruff.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#:
#:[target.ruff-clean]
#:description = Uninstall ruff.
#:

##############################################################################
# ruff
Expand Down
1 change: 0 additions & 1 deletion src/mxmake/topics/qa/zpretty.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#:
#:[target.zpretty-clean]
#:description = Uninstall zpretty.
#:

##############################################################################
# zpretty
Expand Down

0 comments on commit 3d27641

Please sign in to comment.