xonsh/tests/test_platform.py

21 lines
468 B
Python
Raw Normal View History

2022-01-31 21:26:34 +05:30
import builtins
from contextlib import contextmanager
from unittest.mock import MagicMock
import xonsh.platform as xp
def test_githash_value_error(monkeypatch):
@contextmanager
def mocked_open(*args):
2018-08-30 09:18:49 -05:00
yield MagicMock(read=lambda: "abc123")
monkeypatch.setattr(builtins, "open", mocked_open)
sha, date_ = xp.githash()
assert date_ is None
assert sha is None
def test_pathsplit_empty_path():
assert xp.pathsplit("") == ("", "")