Skip to content

Commit

Permalink
[IMP] checklog-odoo - use pytest instead of unittest refs #1
Browse files Browse the repository at this point in the history
  • Loading branch information
baimont committed Oct 10, 2023
1 parent 065d312 commit da6d229
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
source =
checklog-odoo
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<!--- shortdesc-begin -->

Check if an odoo log file contains error, with the possibility to ignore some errors based on regular expressions..
Check if an odoo log file contains error, with the possibility to ignore some errors based on regular expressions.

<!--- shortdesc-end -->

Expand Down
27 changes: 13 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "hatchling.build"
[project]
name = "checklog-odoo"
dynamic = ["version"]
description = ''
description = 'Check if an odoo log file contains error, with the possibility to ignore some errors based on regular expressions'
readme = "README.md"
requires-python = ">=3.7"
license = "MIT"
Expand Down Expand Up @@ -41,10 +41,15 @@ checklog-odoo = "checklog_odoo.cli.checklog:checklog_odoo"
path = "src/checklog_odoo/__about__.py"

[tool.hatch.envs.default]
dependencies = [
"coverage[toml]>=6.5",
"pytest",
dependencies = []

[project.optional-dependencies]
metadata = []
test = [
"pytest",
"coverage[toml]",
]

[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
Expand Down Expand Up @@ -144,20 +149,14 @@ ban-relative-imports = "all"
"tests/**/*" = ["PLR2004", "S101", "TID252"]

[tool.coverage.run]
source_pkgs = ["checklog_odoo", "tests"]
branch = true
parallel = true
omit = [
"src/checklog_odoo/__about__.py",
]
source_pkgs = ["checklog-odoo"]

[tool.coverage.paths]
checklog_odoo = ["checklog_odoo", "*/checklog-odoo/checklog_odoo"]
tests = ["tests", "*/checklog-odoo/tests"]
source = ["src", ".tox/*/site-packages"]

[tool.coverage.report]
show_missing = true
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"pragma: no cover",
]
5 changes: 3 additions & 2 deletions tests/test_checklog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: MIT

import os
import unittest
import pytest

from click.testing import CliRunner

Expand All @@ -13,10 +13,11 @@
DATA_DIR = os.path.join(os.path.dirname(__file__), "data")


class TestChecklog(unittest.TestCase):
class TestChecklog:
def test1(self):
runner = CliRunner()
res = runner.invoke(checklog_odoo, [os.path.join(DATA_DIR, "test1.log")])
print(os.path.join(DATA_DIR, "test1.log"))
assert res.exit_code != 0
expected = "errors that caused failure (2):"
assert expected in res.output
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ extras =
test
metadata
commands =
coverage run -m unittest discover
coverage run -m pytest {posargs}
coverage xml
coverage html

0 comments on commit da6d229

Please sign in to comment.