Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,8 @@ def _parse_lsb_release_content(lines: Iterable[str]) -> Dict[str, str]:

@cached_property
def _uname_info(self) -> Dict[str, str]:
if not self.include_uname:
return {}
try:
cmd = ("uname", "-rs")
stdout = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
Expand Down
3 changes: 3 additions & 0 deletions tests/resources/testdistros/distro/dontincludeuname/bin/uname
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

echo "NetBSD 7.1.1"
9 changes: 9 additions & 0 deletions tests/test_distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,15 @@ def test_empty_release(self):
desired_outcome = {"id": "empty"}
self._test_outcome(desired_outcome)

def test_dontincludeuname(self):
self._setup_for_distro(os.path.join(TESTDISTROS, "distro", "dontincludeuname"))

self.distro = distro.LinuxDistribution(include_uname=False)

assert self.distro.uname_attr("id") == ""
assert self.distro.uname_attr("name") == ""
assert self.distro.uname_attr("release") == ""

def test_unknowndistro_release(self):
self._setup_for_distro(os.path.join(TESTDISTROS, "distro", "unknowndistro"))

Expand Down