Skip to content

Commit b2d747f

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Fix functional tests and mypy on macOS"
2 parents 2b9f802 + 017a44f commit b2d747f

3 files changed

Lines changed: 8 additions & 14 deletions

File tree

nova/tests/fixtures/libvirt.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,6 +2721,11 @@ def setUp(self):
27212721
self.useFixture(fixtures.MonkeyPatch(
27222722
'nova.virt.libvirt.driver.sys.platform', 'linux'))
27232723

2724+
# mock /proc/meminfo access
2725+
self.useFixture(fixtures.MockPatch(
2726+
'nova.virt.libvirt.host.Host._get_avail_memory_kb',
2727+
return_value=10 * 1024 * 1024)) # 10 GB
2728+
27242729
real_exists = os.path.exists
27252730

27262731
def fake_exists(path):

nova/tests/unit/virt/libvirt/test_host.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,23 +1135,11 @@ def test_get_memory_total_file_backed(self):
11351135
self.assertEqual(1048576, self.host.get_memory_mb_total())
11361136

11371137
def test_get_memory_used(self):
1138-
m = mock.mock_open(read_data="""
1139-
MemTotal: 16194180 kB
1140-
MemFree: 233092 kB
1141-
MemAvailable: 8892356 kB
1142-
Buffers: 567708 kB
1143-
Cached: 8362404 kB
1144-
SwapCached: 0 kB
1145-
Active: 8381604 kB
1146-
""")
1147-
with test.nested(
1148-
mock.patch('builtins.open', m, create=True),
1149-
mock.patch.object(host.Host, "get_connection"),
1150-
) as (mock_file, mock_conn):
1138+
with mock.patch.object(host.Host, "get_connection") as mock_conn:
11511139
mock_conn().getInfo.return_value = [
11521140
obj_fields.Architecture.X86_64, 15814, 8, 1208, 1, 1, 4, 2]
11531141

1154-
self.assertEqual(6866, self.host.get_memory_mb_used())
1142+
self.assertEqual(5574, self.host.get_memory_mb_used())
11551143

11561144
def test_sum_domain_memory_mb_file_backed(self):
11571145
class DiagFakeDomain(object):

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ ignore_errors = true
126126

127127
[tool.mypy]
128128
python_version = "3.10"
129+
platform = "linux"
129130
show_column_numbers = true
130131
show_error_context = true
131132
ignore_missing_imports = true

0 commit comments

Comments
 (0)