Instead of having a function passed into this loop, it would probably be clearer to make this into an iterator. Since it's referencing all module level vars anyway you could do something like:

```python
def all_test_identities():
    for mail in mails:
        for givenName in givenNames:
            for sn in sns:
                yield build_identity_dict(REMOTE_USER, mail, givenName, sn)

# Then you can use it in your other tests like:

def _test_foo(self):
    for identity in all_test_identities():
        self.testSomething(etc)
```