xonsh/tests/platform/test_platform.py
Andy Kipp 2ef4e329f7
refactoring: move platform, winutils, macutils to platform submodule (#5549)
https://github.com/xonsh/xonsh/issues/5538
## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
2024-06-29 02:01:15 +02:00

20 lines
468 B
Python

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):
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("") == ("", "")