def test_get_vexrc(self): options = main.get_options(['--config', 'pretends_to_exist']) def fake_open(name, mode): assert name == 'pretends_to_exist' assert mode == 'rb' return BytesIO(b'a=b\n') with patch('os.path.exists', return_value=True), \ patch('vex.config.open', create=True, new=fake_open): vexrc = main.get_vexrc(options, {}) assert vexrc
def test_get_vexrc(self): options = main.get_options(["--config", "pretends_to_exist"]) def fake_open(name, mode): assert name == "pretends_to_exist" assert mode == "rb" return BytesIO(b"a=b\n") with patch("os.path.exists", return_value=True), \ patch("vex.config.open", create=True, new=fake_open): vexrc = main.get_vexrc(options, {}) assert vexrc
def test_get_vexrc_nonexistent(self): options = main.get_options(['--config', 'unlikely_to_exist']) try: main.get_vexrc(options, {}) except exceptions.InvalidVexrc as error: assert 'unlikely_to_exist' in str(error)