Fix broken flake8 configuration
and flake8 errors which were hidden by this breakage.
flake8 --filename options doesn't work as expected:
* it's expected to be a shell pattern, using stdlib's fnmatch.fnmatch function
internally. This funciton thinks that 'cubicweb/x.py' doesn't match 'cubicweb/x.py'
(there must be a reason but that's not the point), hence no file was actually
checked ;
* as this is a list of pattern, each encountered file is checked against each
pattern, leading to run time explosion.
So maintain list of files to check in a separated file and give this list to
flake8 using unix's xarg command.
from cubicweb.pyramid.test import PyramidCWTest
from cubicweb.pyramid import tools
class ToolsTest(PyramidCWTest):
anonymous_allowed = True
def test_clone_user(self):
with self.admin_access.repo_cnx() as cnx:
user = cnx.find('CWUser', login='anon').one()
user.login # fill the cache
clone = tools.clone_user(self.repo, user)
self.assertEqual(clone.eid, user.eid)
self.assertEqual(clone.login, user.login)
self.assertEqual(clone.cw_rset.rows, user.cw_rset.rows)
self.assertEqual(clone.cw_rset.rql, user.cw_rset.rql)
def test_cnx_attach_entity(self):
with self.admin_access.repo_cnx() as cnx:
user = cnx.find('CWUser', login='anon').one()
with self.admin_access.repo_cnx() as cnx:
tools.cnx_attach_entity(cnx, user)
self.assertEqual(user.login, 'anon')
if __name__ == '__main__':
from unittest import main
main()