Skip to content

Commit

Permalink
rm
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-treebeard committed Oct 17, 2023
1 parent 54d1d16 commit 74d30da
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 95 deletions.
39 changes: 0 additions & 39 deletions src/nbmake/metrics.py

This file was deleted.

13 changes: 1 addition & 12 deletions src/nbmake/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from pathlib import Path
from typing import Any, Optional

import nbmake.metrics

try:
from importlib.metadata import version
except ImportError:
Expand Down Expand Up @@ -71,13 +69,4 @@ def pytest_collect_file(path: str, parent: Any) -> Optional[Any]:


def pytest_terminal_summary(terminalreporter: Any, exitstatus: int, config: Any):
if not config.option.nbmake:
return

if os.getenv("NBMAKE_METRICS", "0") != "1":
return

try:
nbmake.metrics.submit_event()
except:
pass
pass
44 changes: 0 additions & 44 deletions tests/test_pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,47 +208,3 @@ def test_when_not_json_then_correct_err_msg(pytester: Pytester, testdir2: Never)
assert longrepr is not None
assert "NBMAKE INTERNAL ERROR" not in longrepr.term
assert "json" in longrepr.term


def test_when_testing_nbs_then_submit_metrics(pytester: Pytester):
write_nb(failing_nb, Path(pytester.path) / "a.ipynb")

with patch("nbmake.metrics.submit_event", return_value="1") as mock_method:
hook_recorder = pytester.inline_run("--nbmake", "-v")
assert hook_recorder.ret == ExitCode.TESTS_FAILED
mock_method.assert_called_once()


def test_when_metrics_fail_then_ignore(pytester: Pytester):
write_nb(failing_nb, Path(pytester.path) / "a.ipynb")

with patch("nbmake.metrics.submit_event", return_value="1") as mock_method:
mock_method.side_effect = Exception("test")
write_nb(passing_nb, Path(pytester.path) / "a.ipynb")

items, hook_recorder = pytester.inline_genitems("--nbmake")

assert hook_recorder.ret == ExitCode.OK
assert len(items) == 1
mock_method.assert_called_once()


def test_when_metrics_disabled_dont_log_metrics(pytester: Pytester):
write_nb(failing_nb, Path(pytester.path) / "a.ipynb")
# not thread-safe
os.environ["NBMAKE_METRICS"] = "0"

with patch("nbmake.metrics.submit_event", return_value="1") as mock_method:
hook_recorder = pytester.inline_run("--nbmake", "-v")
assert hook_recorder.ret == ExitCode.TESTS_FAILED
mock_method.assert_not_called()

del os.environ["NBMAKE_METRICS"]


def test_when_no_nbmake_flag_then_no_metrics(pytester: Pytester):
write_nb(failing_nb, Path(pytester.path) / "a.ipynb")
with patch("nbmake.metrics.submit_event", return_value="1") as mock_method:
hook_recorder = pytester.inline_run("-v")
assert hook_recorder.ret == ExitCode.NO_TESTS_COLLECTED
mock_method.assert_not_called()

0 comments on commit 74d30da

Please sign in to comment.