| 1 |
# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 |
# |
| 3 |
# This source code is licensed under the MIT license found in the |
| 4 |
# LICENSE file in the root directory of this source tree. |
| 5 |
|
| 6 |
|
| 7 |
import unittest |
| 8 |
|
| 9 |
from ..platform import HostType |
| 10 |
|
| 11 |
|
| 12 |
class PlatformTest(unittest.TestCase): |
| 13 |
def test_create(self) -> None: |
| 14 |
p = HostType() |
| 15 |
self.assertNotEqual(p.ostype, None, msg="probed and returned something") |
| 16 |
|
| 17 |
tuple_string = p.as_tuple_string() |
| 18 |
round_trip = HostType.from_tuple_string(tuple_string) |
| 19 |
self.assertEqual(round_trip, p) |
| 20 |
|
| 21 |
def test_rendering_of_none(self) -> None: |
| 22 |
p = HostType(ostype="foo") |
| 23 |
self.assertEqual(p.as_tuple_string(), "foo-none-none") |
| 24 |
|
| 25 |
def test_is_methods(self) -> None: |
| 26 |
p = HostType(ostype="windows") |
| 27 |
self.assertTrue(p.is_windows()) |
| 28 |
self.assertFalse(p.is_darwin()) |
| 29 |
self.assertFalse(p.is_linux()) |
| 30 |
|
| 31 |
p = HostType(ostype="darwin") |
| 32 |
self.assertFalse(p.is_windows()) |
| 33 |
self.assertTrue(p.is_darwin()) |
| 34 |
self.assertFalse(p.is_linux()) |
| 35 |
|
| 36 |
p = HostType(ostype="linux") |
| 37 |
self.assertFalse(p.is_windows()) |
| 38 |
self.assertFalse(p.is_darwin()) |
| 39 |
self.assertTrue(p.is_linux()) |