Add missing test cases for `attribute_names` instance method

There is a class method with the same name that is tested, but not the
instance method.
Merge pull request #15865 from sgrif/sg-missing-test

Add missing test cases for `attribute_names` instance method