From 23acded468ee550b6dd8808f01423d012aa7e004 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Wed, 13 Jan 2016 17:40:01 -0500 Subject: Fix cli unit test override This was not my first choice, but it works. I need to put this in a fixture so it's not duplicated for every cli test function. --- test_dotfiles.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'test_dotfiles.py') diff --git a/test_dotfiles.py b/test_dotfiles.py index 2b93de6..bdb3439 100644 --- a/test_dotfiles.py +++ b/test_dotfiles.py @@ -5,11 +5,14 @@ from dotfiles import Repository, Dotfile, cli class TestCli(object): - @pytest.mark.xfail(reason='global overrides not working') def test_status(self, runner, repo, home, monkeypatch): - # FIXME: this approach does not work - monkeypatch.setattr('dotfiles.DEFAULT_HOMEDIR', str(home)) - monkeypatch.setattr('dotfiles.DEFAULT_REPO_PATH', str(repo)) + + def repo_init(self, *args, **kwargs): + self.ignore = [] + self.homedir = home + self.repodir = repo.ensure(dir=1) + + monkeypatch.setattr(Repository, '__init__', repo_init) result = runner.invoke(cli, ['status']) assert not result.exception -- cgit v1.2.3