diff --git a/.travis.yml b/.travis.yml index 5e63fb7e..efe4e1c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,13 @@ install: - pip install -e .[dev] script: - - pytest --cov loguru/ + - pytest --cov after_success: - - codecov --flags "py${TRAVIS_PYTHON_VERSION//./}" + # Report to codecov, with different flags for tests. + - coverage xml --include 'loguru/*' + - codecov -f coverage.xml --flags loguru "py${TRAVIS_PYTHON_VERSION//./}" --disable search gcov pycov + - coverage xml --include 'tests/*' + - codecov -f coverage.xml --flags tests "py${TRAVIS_PYTHON_VERSION//./}" --disable search gcov pycov + - cd docs && make html diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..8c4ad746 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,10 @@ +coverage: + status: + project: yes + patch: yes + changes: yes + +comment: + layout: "header, diff" + behavior: default + require_changes: no diff --git a/tests/exceptions/enqueue_with_others_handlers.py b/tests/exceptions/enqueue_with_others_handlers.py index d28ac9f0..81db1918 100644 --- a/tests/exceptions/enqueue_with_others_handlers.py +++ b/tests/exceptions/enqueue_with_others_handlers.py @@ -4,8 +4,6 @@ def check_tb_sink(message): exception = message.record["exception"] - if exception is None: - return assert exception.traceback is not None diff --git a/tests/exceptions/nested_wrapping.py b/tests/exceptions/nested_wrapping.py index f97b7001..3f634474 100644 --- a/tests/exceptions/nested_wrapping.py +++ b/tests/exceptions/nested_wrapping.py @@ -24,9 +24,6 @@ def a(x): try: - try: - f(0) - except ZeroDivisionError: - logger.exception("") -except Exception: + f(0) +except ZeroDivisionError: logger.exception("") diff --git a/tests/exceptions/not_enough_arguments.py b/tests/exceptions/not_enough_arguments.py index 007e39d5..77db4a2b 100644 --- a/tests/exceptions/not_enough_arguments.py +++ b/tests/exceptions/not_enough_arguments.py @@ -7,11 +7,11 @@ @logger.catch def decorated(x, y, z): - pass + raise NotImplementedError def not_decorated(x, y, z): - pass + raise NotImplementedError decorated(1) diff --git a/tests/exceptions/output/enqueue_with_others_handlers.txt b/tests/exceptions/output/enqueue_with_others_handlers.txt index 0a9854d1..8d69512f 100644 --- a/tests/exceptions/output/enqueue_with_others_handlers.txt +++ b/tests/exceptions/output/enqueue_with_others_handlers.txt @@ -1,7 +1,7 @@ Traceback (most recent call last): -> File "tests/exceptions/enqueue_with_others_handlers.py", line 19, in +> File "tests/exceptions/enqueue_with_others_handlers.py", line 17, in 1 / 0 ZeroDivisionError: division by zero diff --git a/tests/exceptions/output/nested_wrapping.txt b/tests/exceptions/output/nested_wrapping.txt index 137c0a9d..05decf41 100644 --- a/tests/exceptions/output/nested_wrapping.txt +++ b/tests/exceptions/output/nested_wrapping.txt @@ -30,7 +30,7 @@ ZeroDivisionError: division by zero Traceback (most recent call last): -> File "tests/exceptions/nested_wrapping.py", line 28, in +> File "tests/exceptions/nested_wrapping.py", line 27, in f(0) └ diff --git a/tests/exceptions/too_many_arguments.py b/tests/exceptions/too_many_arguments.py index 93d90828..14689b6b 100644 --- a/tests/exceptions/too_many_arguments.py +++ b/tests/exceptions/too_many_arguments.py @@ -7,11 +7,11 @@ @logger.catch def decorated(): - pass + raise NotImplementedError def not_decorated(): - pass + raise NotImplementedError decorated(1) diff --git a/tests/test_add_options.py b/tests/test_add_options.py index 35051d7c..21e779f8 100644 --- a/tests/test_add_options.py +++ b/tests/test_add_options.py @@ -363,7 +363,7 @@ def test_disabled_logger_in_sink(sink_with_logger): def test_invalid_function_kwargs(): def function(message, a="Y"): - pass + raise NotImplementedError logger.add(function, b="X", catch=False) with pytest.raises(TypeError): @@ -384,7 +384,7 @@ def __init__(self): self.out = "" def write(self, m): - pass + raise NotImplementedError writer = Writer() logger.add(writer, format="{message}", kw1="1", kw2="2", catch=False) diff --git a/tests/test_exceptions_formatting.py b/tests/test_exceptions_formatting.py index 0f19f379..012276a6 100644 --- a/tests/test_exceptions_formatting.py +++ b/tests/test_exceptions_formatting.py @@ -21,7 +21,7 @@ def normalize(formatted_exception): return formatted_exception -def generate(output, outpath): +def generate(output, outpath): # pragma: no cover """Generate new output file if exception formatting is updated""" with open(outpath, "w") as file: file.write(output) diff --git a/tests/test_threading.py b/tests/test_threading.py index 82f00517..49b5eec0 100644 --- a/tests/test_threading.py +++ b/tests/test_threading.py @@ -11,8 +11,7 @@ def __init__(self, sleep_time): self.stopped = False def write(self, message): - if self.stopped: - raise RuntimeError("Can't write on stopped sink") + assert not self.stopped length = len(message) self.written += message[:length] diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..5358a29f --- /dev/null +++ b/tox.ini @@ -0,0 +1,8 @@ +[coverage:run] +source = . + +[coverage:report] +include = loguru/*, tests/* +exclude_lines = + \#\s*pragma: no cover + ^\s*raise NotImplementedError\b