mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-30 06:11:26 -07:00
Bundle a copy of github.com/nir0s/distro/distro.py
Since the 'platform.dist()' and 'platform.linux_distribution()' methods will be removed from future versions of python, this provides an alternative to replace ansibles use of those methods. lib/ansible/module_utils/distro.py is a copy of https://github.com/nir0s/distro/blob/master/distro.py This module is originally from https://github.com/nir0s/distro and is license under the Apache License, Version 2.0.
This commit is contained in:
parent
61a649ce0f
commit
5e1f8a48f3
4 changed files with 1484 additions and 0 deletions
32
test/units/module_utils/test_distro.py
Normal file
32
test/units/module_utils/test_distro.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
|
||||
# (c) 2018 Adrian Likins <alikins@redhat.com>
|
||||
# Copyright (c) 2018 Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# or
|
||||
# Apache License v2.0 (see http://www.apache.org/licenses/LICENSE-2.0)
|
||||
#
|
||||
# Dual licensed so any test cases could potentially be included by the upstream project
|
||||
# that module_utils/distro.py is from (https://github.com/nir0s/distro)
|
||||
|
||||
|
||||
# Note that nir0s/distro has many more tests in it's test suite. The tests here are
|
||||
# primarily for testing the vendoring.
|
||||
|
||||
import pytest
|
||||
|
||||
from ansible.module_utils import distro
|
||||
|
||||
|
||||
# Generic test case with minimal assertions about specific returned values.
|
||||
class TestDistro():
|
||||
# should run on any platform without errors, even if non-linux without any
|
||||
# useful info to return
|
||||
def test_info(self):
|
||||
info = distro.info()
|
||||
assert isinstance(info, dict), \
|
||||
'distro.info() returned %s (%s) which is not a dist' % (info, type(info))
|
||||
|
||||
def test_linux_distribution(self):
|
||||
linux_dist = distro.linux_distribution()
|
||||
assert isinstance(linux_dist, tuple), \
|
||||
'linux_distrution() returned %s (%s) which is not a tuple' % (linux_dist, type(linux_dist))
|
Loading…
Add table
Add a link
Reference in a new issue