Commit 83b8fe89 authored by Jérome Perrin's avatar Jérome Perrin

erp5_test_core: pylint

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