You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The behavior of Mock(spec=foo) or Mock(spec_set=foo) when foo is not a
list is to interpret foo as a class or instance and derive the set of
attributes you're allowed to get (spec) and/or set (spec_set) based on
dir(foo) [1]. Thus if foo is a string, your mock will be set up to look
like a string (with attributes like index, find, startswith...).
So for example, if you see:
Mock(spec='nova.objects.Instance')
...what was almost certainly intended was:
Mock(spec=nova.objects.Instance)
This commit fixes all such cases in the nova codebase, making those
specs point to the actual classes as intended.
A subsequent commit will introduce a hacking rule to ensure this mistake
isn't repeated in the future.
[1] https://docs.python.org/3/library/unittest.mock.html#the-mock-class
Change-Id: I924edd474a798aa32bb8fb88ba6d84815a8bf93e
0 commit comments