Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KED-950] Turn on the branch coverage for unit tests #267

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[run]
branch=True
[report]
fail_under=100
show_missing=True
Expand Down
1 change: 1 addition & 0 deletions tests/config/test_templated_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ class TestFormatObject:
({"key": "${a}"}, {"a": "A"}, {"key": "A"}),
({"${a}": "value"}, {"a": "A"}, {"A": "value"}),
({"${a|D}": "value"}, {}, {"D": "value"}),
({1: "${a}"}, {"a": "A"}, {1: "A"}),
],
)
def test_simple_replace(self, val, format_dict, expected):
Expand Down
10 changes: 10 additions & 0 deletions tests/template/test_load_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ def test_valid_context(self, mocker, fake_repo_path):
assert str(fake_repo_path.resolve() / "src") in sys.path
assert os.getcwd() == str(fake_repo_path.resolve())

def test_loading_valid_context_twice(self, mocker, fake_repo_path):
"""Test getting project context twice."""
mocker.patch("logging.config.dictConfig")
load_context(str(fake_repo_path))
result = load_context(str(fake_repo_path))
assert result.project_name == "Test Project"
assert result.project_version == kedro.__version__
assert str(fake_repo_path.resolve() / "src") in sys.path
assert os.getcwd() == str(fake_repo_path.resolve())

def test_invalid_path(self, tmp_path):
"""Test for loading context from an invalid path. """
other_path = tmp_path / "other"
Expand Down
6 changes: 6 additions & 0 deletions tests/tools/ipython/test_ipython_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,9 @@ def test_ipython_loader_main(self, mocker, dummy_project_dir, caplog):
script_path
)
assert caplog.records[0].message == expected_message

def test_no_dir_ipython_loader_main(self, mocker):
mocker.patch("pathlib.Path.cwd", return_value="/")
mocker.spy(ipython_loader, "run_startup_scripts")
ipython_loader.main()
ipython_loader.run_startup_scripts.assert_not_called()