Skip to content

Commit 6aa9511

Browse files
committed
default to using linux platform
If there is no pages directory for the user's current platform, then just assume it's a Linux-like and serve from there. Certain results may be different (e.g. GNU grep vs BSD grep), but better than nothing. Signed-off-by: Matthew Peveler <[email protected]>
1 parent 8744b1b commit 6aa9511

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

tests/test_tldr.py

+13
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,16 @@ def test_get_default_language(language, expected, monkeypatch):
5959
def test_get_default_language_unset(monkeypatch):
6060
monkeypatch.delenv("LANG", raising=False)
6161
assert tldr.get_default_language() is None
62+
63+
64+
@pytest.mark.parametrize("platform, expected", [
65+
("linux2", "linux"),
66+
("win32", "windows"),
67+
("darwin", "osx"),
68+
("sunos", "sunos"),
69+
("freebsd", "linux"),
70+
("aix", "linux"),
71+
])
72+
def test_get_platform(platform, expected):
73+
with mock.patch("sys.platform", platform):
74+
assert tldr.get_platform() == expected

tldr.py

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def get_platform():
172172
for key in OS_DIRECTORIES:
173173
if sys.platform.startswith(key):
174174
return OS_DIRECTORIES[key]
175+
return 'linux'
175176

176177

177178
def get_platform_list():

0 commit comments

Comments
 (0)