Commit 5a619281 authored by Jérome Perrin's avatar Jérome Perrin

erp5_test_core: pylint

parent d4992b83
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
import io import io
import unittest import unittest
import os
from unittest import skip from unittest import skip
from Testing import ZopeTestCase from Testing import ZopeTestCase
...@@ -1048,8 +1047,6 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -1048,8 +1047,6 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertEqual(None, obj.getViewPermissionOwner()) self.assertEqual(None, obj.getViewPermissionOwner())
def test_Member_Base_download(self): def test_Member_Base_download(self):
import Products.ERP5Type
# tests that members can download files # tests that members can download files
class DummyFile(io.BytesIO): class DummyFile(io.BytesIO):
filename = 'dummy.txt' filename = 'dummy.txt'
......
...@@ -12,10 +12,12 @@ ...@@ -12,10 +12,12 @@
############################################################################## ##############################################################################
import six import six
# pylint:disable=no-name-in-module
if six.PY2: if six.PY2:
from base64 import encodestring as base64_encodebytes from base64 import encodestring as base64_encodebytes
else: else:
from base64 import encodebytes as base64_encodebytes from base64 import encodebytes as base64_encodebytes
# pylint:enable=no-name-in-module
from six.moves import cStringIO as StringIO from six.moves import cStringIO as StringIO
import unittest import unittest
from six.moves.urllib.parse import quote from six.moves.urllib.parse import quote
......
...@@ -36,7 +36,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase ...@@ -36,7 +36,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.utils import createZODBPythonScript, FileUpload from Products.ERP5Type.tests.utils import createZODBPythonScript, FileUpload
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
import six
class TestERP5Base(ERP5TypeTestCase): class TestERP5Base(ERP5TypeTestCase):
"""ERP5 Base tests. """ERP5 Base tests.
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
############################################################################## ##############################################################################
import unittest import unittest
import sys
import mock import mock
import transaction import transaction
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
# #
############################################################################## ##############################################################################
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.Globals import PersistentMapping from Products.ERP5Type.Globals import PersistentMapping
......
...@@ -67,7 +67,7 @@ def old(items): ...@@ -67,7 +67,7 @@ def old(items):
if len(whl._log) < 16: if len(whl._log) < 16:
whl._log.append(item) whl._log.append(item)
else: else:
prev = whl.__new__(whl.__class__) prev = whl.__new__(whl.__class__) # pylint:disable=no-value-for-parameter
prev._prev = whl._prev prev._prev = whl._prev
prev._log = whl._log prev._log = whl._log
whl._prev = prev whl._prev = prev
...@@ -91,7 +91,8 @@ class TestWorkflowHistoryList(TestCase): ...@@ -91,7 +91,8 @@ class TestWorkflowHistoryList(TestCase):
self.assertEqual(ddl, new(type(ddl), EXPECTED)) self.assertEqual(ddl, new(type(ddl), EXPECTED))
class check(object): class check(object):
def __getitem__(_, item): # pylint: disable=no-self-argument def __getitem__(self_, item): # pylint: disable=no-self-argument
del self_
try: try:
a = EXPECTED[item] a = EXPECTED[item]
except IndexError: except IndexError:
......
...@@ -30,7 +30,7 @@ from Products.ERP5Type.tests.runUnitTest import log_directory ...@@ -30,7 +30,7 @@ from Products.ERP5Type.tests.runUnitTest import log_directory
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
import os import os
import requests import requests
import unittest
def get_Z2_log_last_line(): def get_Z2_log_last_line():
z2_log_path = os.path.join(log_directory, 'Z2.log') z2_log_path = os.path.join(log_directory, 'Z2.log')
...@@ -43,6 +43,7 @@ def get_Z2_log_last_line(): ...@@ -43,6 +43,7 @@ def get_Z2_log_last_line():
f.close() f.close()
return last_line return last_line
class TestXForwardedFor(ERP5TypeTestCase): class TestXForwardedFor(ERP5TypeTestCase):
def test_request_with_x_forwarded_for(self): def test_request_with_x_forwarded_for(self):
script_container = self.portal.portal_skins.custom script_container = self.portal.portal_skins.custom
...@@ -56,6 +57,7 @@ class TestXForwardedFor(ERP5TypeTestCase): ...@@ -56,6 +57,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
response = requests.get( response = requests.get(
'%s/%s' % (self.portal.absolute_url(), script_id), '%s/%s' % (self.portal.absolute_url(), script_id),
headers={'X-Forwarded-For': '1.2.3.4'}, headers={'X-Forwarded-For': '1.2.3.4'},
timeout=5,
) )
self.assertNotEqual(response.text, '1.2.3.4') self.assertNotEqual(response.text, '1.2.3.4')
last_line = get_Z2_log_last_line() last_line = get_Z2_log_last_line()
...@@ -63,6 +65,7 @@ class TestXForwardedFor(ERP5TypeTestCase): ...@@ -63,6 +65,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
response = requests.get( response = requests.get(
'%s/%s' % (self.portal.absolute_url(), script_id), '%s/%s' % (self.portal.absolute_url(), script_id),
headers={'X-Forwarded-For': '1.2.3.4, 5.6.7.8'}, headers={'X-Forwarded-For': '1.2.3.4, 5.6.7.8'},
timeout=5,
) )
self.assertNotEqual(response.text, '1.2.3.4') self.assertNotEqual(response.text, '1.2.3.4')
self.assertNotEqual(response.text, '5.6.7.8') self.assertNotEqual(response.text, '5.6.7.8')
...@@ -71,6 +74,7 @@ class TestXForwardedFor(ERP5TypeTestCase): ...@@ -71,6 +74,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
self.assertFalse(last_line.startswith('5.6.7.8 - '), last_line) self.assertFalse(last_line.startswith('5.6.7.8 - '), last_line)
response = requests.get( response = requests.get(
'%s/%s' % (self.portal.absolute_url(), script_id), '%s/%s' % (self.portal.absolute_url(), script_id),
timeout=5,
) )
self.assertNotEqual(response.text, '1.2.3.4') self.assertNotEqual(response.text, '1.2.3.4')
last_line = get_Z2_log_last_line() last_line = get_Z2_log_last_line()
...@@ -81,6 +85,7 @@ class TestXForwardedFor(ERP5TypeTestCase): ...@@ -81,6 +85,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
response = requests.get( response = requests.get(
'%s/%s' % (self.portal.absolute_url(), script_id), '%s/%s' % (self.portal.absolute_url(), script_id),
headers={'X-Forwarded-For': '1.2.3.4'}, headers={'X-Forwarded-For': '1.2.3.4'},
timeout=5,
) )
self.assertEqual(response.text, '1.2.3.4') self.assertEqual(response.text, '1.2.3.4')
last_line = get_Z2_log_last_line() last_line = get_Z2_log_last_line()
...@@ -88,18 +93,15 @@ class TestXForwardedFor(ERP5TypeTestCase): ...@@ -88,18 +93,15 @@ class TestXForwardedFor(ERP5TypeTestCase):
response = requests.get( response = requests.get(
'%s/%s' % (self.portal.absolute_url(), script_id), '%s/%s' % (self.portal.absolute_url(), script_id),
headers={'X-Forwarded-For': '1.2.3.4, 5.6.7.8'}, headers={'X-Forwarded-For': '1.2.3.4, 5.6.7.8'},
timeout=5,
) )
self.assertEqual(response.text, '1.2.3.4') self.assertEqual(response.text, '1.2.3.4')
last_line = get_Z2_log_last_line() last_line = get_Z2_log_last_line()
self.assertTrue(last_line.startswith('1.2.3.4 - '), last_line) self.assertTrue(last_line.startswith('1.2.3.4 - '), last_line)
response = requests.get( response = requests.get(
'%s/%s' % (self.portal.absolute_url(), script_id), '%s/%s' % (self.portal.absolute_url(), script_id),
timeout=5,
) )
self.assertNotEqual(response.text, '1.2.3.4') self.assertNotEqual(response.text, '1.2.3.4')
last_line = get_Z2_log_last_line() last_line = get_Z2_log_last_line()
self.assertFalse(last_line.startswith('1.2.3.4 - '), last_line) self.assertFalse(last_line.startswith('1.2.3.4 - '), last_line)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestXForwardedFor))
return suite
...@@ -60,10 +60,10 @@ class XMLPickleTestCase(unittest.TestCase): ...@@ -60,10 +60,10 @@ class XMLPickleTestCase(unittest.TestCase):
class DummyJar: class DummyJar:
loaded = None loaded = None
"""follow interface expected by importXML""" """follow interface expected by importXML"""
def importFile(self, file, clue): def importFile(self, file_, clue):
assertEqual(clue, 'ignored') assertEqual(clue, 'ignored')
assertEqual(file.read(4), b'ZEXP') assertEqual(file_.read(4), b'ZEXP')
unpickler = pickle.Unpickler(file) unpickler = pickle.Unpickler(file_)
if persistent_load: if persistent_load:
unpickler.persistent_load = persistent_load unpickler.persistent_load = persistent_load
self.loaded = unpickler.load() self.loaded = unpickler.load()
...@@ -126,6 +126,7 @@ class TestXMLPickle(XMLPickleTestCase): ...@@ -126,6 +126,7 @@ class TestXMLPickle(XMLPickleTestCase):
if six.PY2: if six.PY2:
def test_long(self): def test_long(self):
# pylint:disable=undefined-variable
self.check_and_load(long(-0)) self.check_and_load(long(-0))
self.check_and_load(long(1)) self.check_and_load(long(1))
self.check_and_load(long(-1)) self.check_and_load(long(-1))
...@@ -134,6 +135,7 @@ class TestXMLPickle(XMLPickleTestCase): ...@@ -134,6 +135,7 @@ class TestXMLPickle(XMLPickleTestCase):
self.check_and_load(long(0xffff)) self.check_and_load(long(0xffff))
self.check_and_load(long(2**128)) self.check_and_load(long(2**128))
self.check_and_load(12345678910111213141516178920 << (256*8)) self.check_and_load(12345678910111213141516178920 << (256*8))
# pylint:enable=undefined-variable
def test_float(self): def test_float(self):
self.check_and_load(-0.0) self.check_and_load(-0.0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment