Fix for issue #8519

Also added a test that fails prior to the fix, illustrating the problem.
Merge pull request #8519 from emilisto/develop

pip state module requires name even if requirements file is specified