Example #1
0
 def __new__(cls, *args, **kwargs):
     new_cls = get_platform_subclass(TCPConnectionInfo)
     return super(cls, new_cls).__new__(new_cls)
Example #2
0
 def __new__(cls, *args, **kwargs):
     new_cls = get_platform_subclass(Hostname)
     return super(cls, new_cls).__new__(new_cls)
Example #3
0
 def test_get_distribution_none(self):
     # match just the platform class, not a specific distribution
     with patch('ansible.module_utils.common.sys_info.get_distribution',
                return_value=None):
         assert get_platform_subclass(self.LinuxTest) is self.Foo
Example #4
0
 def test_get_distribution_found(self):
     # match both the distribution and platform class
     with patch('ansible.module_utils.common.sys_info.get_distribution',
                return_value="Bar"):
         assert get_platform_subclass(self.LinuxTest) is self.Bar
Example #5
0
 def test_not_linux(self):
     # if neither match, the fallback should be the top-level class
     with patch('platform.system', return_value="Foo"):
         with patch('ansible.module_utils.common.sys_info.get_distribution',
                    return_value=None):
             assert get_platform_subclass(self.LinuxTest) is self.LinuxTest