blob: ef952393a9805b4509fd596f5b5a7f9946a0bf3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# -*- coding: utf-8 -*-
# (c) 2018 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
from ansible.module_utils.common.sys_info import get_all_subclasses
#
# Tests for get_all_subclasses
#
class TestGetAllSubclasses:
class Base:
pass
class BranchI(Base):
pass
class BranchII(Base):
pass
class BranchIA(BranchI):
pass
class BranchIB(BranchI):
pass
class BranchIIA(BranchII):
pass
class BranchIIB(BranchII):
pass
def test_bottom_level(self):
assert get_all_subclasses(self.BranchIIB) == set()
def test_one_inheritance(self):
assert set(get_all_subclasses(self.BranchII)) == set([self.BranchIIA, self.BranchIIB])
def test_toplevel(self):
assert set(get_all_subclasses(self.Base)) == set([self.BranchI, self.BranchII,
self.BranchIA, self.BranchIB,
self.BranchIIA, self.BranchIIB])
|