nova/nova/tests/unit/pci
Adam Spiers ca8f4be2a8 Move selective patching of open() to nova.test for reuse
Several existing tests patch open() to fake the contents of a file
outside the test virtualenv, whilst avoiding interfering with reading
and writing of other files inside the test virtualenv.  Currently they
do it by duplicating logic.

Furthermore, in the near future, more tests (specifically, some SEV
tests) will want to do the same selective patching, and similarly will
need to avoid impacting reads of other files within the test
virtualenv, e.g. placement-policy.yaml.

So create new patch_open() context manager / decorator in nova.test
for selectively patching open based on the path parameter, and reuse
this for existing tests.

Also add unit tests for all these cases.

mock >= 3.0.0 is required because configparser.RawConfigParser._read()
uses enumerate() to iterate over the lines of the (mocked)
/etc/nova/release config file, and this uses __iter__() under the hood
which was not supported via mock_open until a bug was fixed and
backported to the external mock library for 3.0.0:

    https://bugs.python.org/issue21258
    https://bugs.python.org/issue32933
    73f6eed0d6

Change-Id: I19f49c923d2c41eab0c7b4cab28c50498dc07046
2019-05-25 02:49:40 +00:00
..
__init__.py move all tests to nova/tests/unit 2014-11-12 15:31:08 -05:00
fakes.py Fix mock.patch usage in unit tests 2018-09-13 02:54:07 +00:00
test_devspec.py Merge "pci: Validate behavior of empty devname" 2017-09-21 13:57:54 +00:00
test_manager.py Separate methods to free claimed and allocated devs 2019-03-07 10:21:41 +02:00
test_request.py Add get_instance_pci_request_from_vif 2019-03-07 11:37:53 +02:00
test_stats.py Address nits in I46d483f9de6776db1b025f925890624e5e682ada 2018-01-02 15:57:50 +00:00
test_utils.py Move selective patching of open() to nova.test for reuse 2019-05-25 02:49:40 +00:00
test_whitelist.py Enhance PCI passthrough whitelist to support regex 2016-12-11 00:53:14 +02:00