Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/test_accessor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from pyfakefs.fake_filesystem import FakeFilesystem

Check failure on line 3 in tests/test_accessor.py

View workflow job for this annotation

GitHub Actions / test (3.11, ubuntu-22.04)

pylint E0611: no-name-in-module

No name 'fake_filesystem' in module 'pyfakefs'

Check failure on line 3 in tests/test_accessor.py

View workflow job for this annotation

GitHub Actions / test (3.11, ubuntu-22.04)

pylint E0401: import-error

Unable to import 'pyfakefs.fake_filesystem'

Check failure on line 3 in tests/test_accessor.py

View workflow job for this annotation

GitHub Actions / test (3.11, ubuntu-22.04)

pylint E0611: no-name-in-module

No name 'fake_filesystem' in module 'pyfakefs'

Check failure on line 3 in tests/test_accessor.py

View workflow job for this annotation

GitHub Actions / test (3.11, ubuntu-22.04)

pylint E0401: import-error

Unable to import 'pyfakefs.fake_filesystem'

import xcp.accessor

Expand All @@ -18,7 +18,7 @@

class TestAccessor(unittest.TestCase):
def setUp(self):
"""Provide the refrence content of the repo/.treeinfo file for check_repo_access()"""
"""Provide the reference content of the repo/.treeinfo file for check_repo_access()"""
with open("tests/data/repo/.treeinfo", "rb") as dot_treeinfo:
self.reference_treeinfo = dot_treeinfo.read()

Expand All @@ -35,6 +35,7 @@
self.assertFalse(a.access('no_such_file'))
self.assertEqual(a.lastError, 404)
a.finish()
a.finish() # Cover the code handing a 2nd call of accessor.finish()

def test_filesystem_accessor_access(self):
"""Test FilesystemAccessor.access()"""
Expand Down
1 change: 1 addition & 0 deletions tests/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ def test_openLog_mock_stdin():
assert openLog("test.log") is True
os.close(slave_fd)
os.close(master_fd)
open_mock.assert_called_once_with("test.log", "a", **open_utf8)
23 changes: 22 additions & 1 deletion tests/test_pci.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import unittest
from os import environ

import pyfakefs.fake_filesystem_unittest

Check failure on line 6 in tests/test_pci.py

View workflow job for this annotation

GitHub Actions / test (3.11, ubuntu-22.04)

pylint E0401: import-error

Unable to import 'pyfakefs.fake_filesystem_unittest'

Check failure on line 6 in tests/test_pci.py

View workflow job for this annotation

GitHub Actions / test (3.11, ubuntu-22.04)

pylint E0401: import-error

Unable to import 'pyfakefs.fake_filesystem_unittest'
import pytest
from mock import Mock, patch

Expand Down Expand Up @@ -31,6 +31,7 @@

def test_null_with_segment(self):

assert PCI.is_valid("0000:00:00.0") is True
c = PCI("0000:00:00.0")

self.assertEqual(c.segment, 0)
Expand All @@ -43,6 +44,7 @@

def test_null_without_segment(self):

assert PCI.is_valid("00:00.0") is True
c = PCI("00:00.0")

self.assertEqual(c.segment, 0)
Expand All @@ -54,28 +56,47 @@

def test_valid(self):

assert PCI.is_valid("8765:43:1f.3") is True
c = PCI("8765:43:1f.3")

self.assertEqual(c.segment, 0x8765)
self.assertEqual(c.bus, 0x43)
self.assertEqual(c.device, 0x1f)
self.assertEqual(c.function, 0x3)

def test_valid_index(self):

assert PCI.is_valid("8765:43:1f.3[0]") is True
assert PCI.is_valid("1234:56:01.7[1]") is True
c = PCI("1234:56:01.7[1]")

self.assertEqual(c.segment, 0x1234)
self.assertEqual(c.bus, 0x56)
self.assertEqual(c.device, 0x01)
self.assertEqual(c.function, 0x7)
self.assertEqual(c.index, 0x1)

def test_equality(self):

self.assertEqual(PCI("0000:00:00.0"), PCI("00:00.0"))
assert PCI("1234:56:01.7[1]") != PCI("1234:56:01.7[2]")
assert PCI("1234:56:01.2") >= PCI("1234:56:01.2")
assert PCI("1234:56:01.1") <= PCI("1234:56:01.2")
assert PCI("1234:56:01.3") > PCI("1234:56:01.2")
assert PCI("1234:56:01.1") < PCI("1234:56:02.2")


if sys.version_info >= (2, 7):
def assert_videoclass_devices(ids, devs): # type: (PCIIds, PCIDevices) -> None
"""Verification function for checking the otuput of PCIDevices.findByClass()"""
"""Verification function for checking the output of PCIDevices.findByClass()"""
video_class = ids.lookupClass('Display controller')
assert video_class == ["03"]
sorted_devices = sorted(devs.findByClass(video_class),
key=lambda x: x['id'])

# Assert devs.findByClass() finding 3 GPUs from tests/data/lspci-mn in our mocked PCIIds DB:
assert len(sorted_devices) == 3
assert len(devs.findByClass("03", "80")) == 2

# For each of the found devices, assert these expected values:
for (video_dev,
Expand Down
Loading