From fd224d8c38c20e610a7963d2445eddd072486f3f Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Mon, 4 May 2020 22:01:31 +0100 Subject: [PATCH] add test for config.set_repo --- tests/config.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/config.py b/tests/config.py index ba95017..8f6f5ad 100644 --- a/tests/config.py +++ b/tests/config.py @@ -55,4 +55,29 @@ Some misc stuff pass -# TODO test set_repo? +def test_set_repo(tmp_path: Path) -> None: + from my.cfg import config + from types import SimpleNamespace + config.hypothesis = SimpleNamespace( # type: ignore[misc,assignment] + export_path='whatever', + ) + + # precondition: + # should fail because can't find hypexport + with pytest.raises(ModuleNotFoundError): + import my.hypothesis + + fake_hypexport = tmp_path / 'hypexport' + fake_hypexport.mkdir() + (fake_hypexport / 'dal.py').write_text(''' +Highlight = None +Page = None +DAL = None + ''') + + from my.cfg import set_repo + # FIXME meh. hot sure about setting the parent?? + set_repo('hypexport', tmp_path) + + # should succeed now! + import my.hypothesis