summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>2019-11-08 18:15:35 +0100
committerPhilippe Pepiot <philippe.pepiot@logilab.fr>2019-11-08 18:15:35 +0100
commit12660bb7e311cb8cf9902b356d54e16f2b6e205f (patch)
tree1828a176889f928ef6dc1c6afc4e7e035207fe17
parent1294e4739b6a24b21a6802a0b5a561ea4890679f (diff)
parent553354d15b11c52c803bc0f812bb6bdb2c4fc6ac (diff)
downloadlogilab-common-12660bb7e311cb8cf9902b356d54e16f2b6e205f.tar.gz
Merge public heads
-rw-r--r--__pkginfo__.py22
-rw-r--r--logilab/common/decorators.py6
-rw-r--r--logilab/common/pytest.py10
-rw-r--r--setup.py8
-rw-r--r--test/unittest_textutils.py22
5 files changed, 40 insertions, 28 deletions
diff --git a/__pkginfo__.py b/__pkginfo__.py
index a5bab40..f8e7e3b 100644
--- a/__pkginfo__.py
+++ b/__pkginfo__.py
@@ -3,22 +3,26 @@
#
# This file is part of logilab-common.
#
-# logilab-common is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 2.1 of the License, or (at your option) any
-# later version.
+# logilab-common is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by the
+# Free Software Foundation, either version 2.1 of the License, or (at your
+# option) any later version.
#
# logilab-common is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
-# You should have received a copy of the GNU Lesser General Public License along
-# with logilab-common. If not, see <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU Lesser General Public License
+# along with logilab-common. If not, see <http://www.gnu.org/licenses/>.
+
"""logilab.common packaging information"""
+
__docformat__ = "restructuredtext en"
+
import sys
import os
+from os.path import join
distname = 'logilab-common'
modname = 'common'
@@ -28,15 +32,15 @@ subpackage_master = True
numversion = (1, 4, 4)
version = '.'.join([str(num) for num in numversion])
-license = 'LGPL' # 2.1 or later
-description = "collection of low-level Python packages and modules used by Logilab projects"
+license = 'LGPL' # 2.1 or later
+description = ("collection of low-level Python packages and modules"
+ " used by Logilab projects")
web = "http://www.logilab.org/project/%s" % distname
mailinglist = "mailto://python-projects@lists.logilab.org"
author = "Logilab"
author_email = "contact@logilab.fr"
-from os.path import join
scripts = [join('bin', 'logilab-pytest')]
include_dirs = [join('test', 'data')]
diff --git a/logilab/common/decorators.py b/logilab/common/decorators.py
index 63504ad..9ec1b5f 100644
--- a/logilab/common/decorators.py
+++ b/logilab/common/decorators.py
@@ -23,7 +23,7 @@ __docformat__ = "restructuredtext en"
import sys
import types
-from time import clock, time
+from time import process_time, time
from inspect import isgeneratorfunction
import six
@@ -232,10 +232,10 @@ class iclassmethod(object):
def timed(f):
def wrap(*args, **kwargs):
t = time()
- c = clock()
+ c = process_time()
res = f(*args, **kwargs)
print('%s clock: %.9f / time: %.9f' % (f.__name__,
- clock() - c, time() - t))
+ process_time() - c, time() - t))
return res
return wrap
diff --git a/logilab/common/pytest.py b/logilab/common/pytest.py
index c644a61..5c62816 100644
--- a/logilab/common/pytest.py
+++ b/logilab/common/pytest.py
@@ -115,7 +115,7 @@ FILE_RESTART = ".pytest.restart"
import os, sys, re
import os.path as osp
-from time import time, clock
+from time import process_time, time
import warnings
import types
import inspect
@@ -385,7 +385,7 @@ class PyTester(object):
print((' %s ' % osp.basename(filename)).center(70, '='),
file=sys.__stderr__)
try:
- tstart, cstart = time(), clock()
+ tstart, cstart = time(), process_time()
try:
testprog = SkipAwareTestProgram(modname, batchmode=batchmode, cvg=self.cvg,
options=self.options, outstream=sys.stderr)
@@ -406,7 +406,7 @@ class PyTester(object):
traceback.print_exc(file=sys.stderr)
return None
- tend, cend = time(), clock()
+ tend, cend = time(), process_time()
ttime, ctime = (tend - tstart), (cend - cstart)
self.report.feed(filename, testprog.result, ttime, ctime)
return testprog
@@ -515,10 +515,10 @@ class DjangoTester(PyTester):
file=sys.stderr)
try:
try:
- tstart, cstart = time(), clock()
+ tstart, cstart = time(), process_time()
self.before_testfile()
testprog = SkipAwareTestProgram(modname, batchmode=batchmode, cvg=self.cvg)
- tend, cend = time(), clock()
+ tend, cend = time(), process_time()
ttime, ctime = (tend - tstart), (cend - cstart)
self.report.feed(filename, testprog.result, ttime, ctime)
return testprog
diff --git a/setup.py b/setup.py
index c565ee1..5ba47d1 100644
--- a/setup.py
+++ b/setup.py
@@ -5,10 +5,10 @@
#
# This file is part of logilab-common.
#
-# logilab-common is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 2.1 of the License, or (at your option) any
-# later version.
+# logilab-common is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by the
+# Free Software Foundation, either version 2.1 of the License, or (at your
+# option) any later version.
#
# logilab-common is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
diff --git a/test/unittest_textutils.py b/test/unittest_textutils.py
index 2fa648a..3e9a343 100644
--- a/test/unittest_textutils.py
+++ b/test/unittest_textutils.py
@@ -104,6 +104,7 @@ aller discuter avec les autres si c'est utile ou necessaire.""")
> .. _extrait:
> http://www.editions-eni.fr/Livres/Python-Les-fondamentaux-du-langage---La-programmation-pour-les-scientifiques-Extrait-du-livre/.20_d6eed0be-0d36-4384-be59-2dd09e081012_0_0.pdf""")
+
class NormalizeParagraphTC(TestCase):
def test_known_values(self):
@@ -167,15 +168,15 @@ class UnitsTC(TestCase):
def test_unit_singleunit_singleletter(self):
result = tu.apply_units('15m', self.units)
- self.assertEqual(result, 15 * self.units['m'] )
+ self.assertEqual(result, 15 * self.units['m'])
def test_unit_singleunit_multipleletter(self):
result = tu.apply_units('47KB', self.units)
- self.assertEqual(result, 47 * self.units['kb'] )
+ self.assertEqual(result, 47 * self.units['kb'])
def test_unit_singleunit_caseinsensitive(self):
result = tu.apply_units('47kb', self.units)
- self.assertEqual(result, 47 * self.units['kb'] )
+ self.assertEqual(result, 47 * self.units['kb'])
def test_unit_multipleunit(self):
result = tu.apply_units('47KB 1.5MB', self.units)
@@ -186,15 +187,22 @@ class UnitsTC(TestCase):
self.assertEqual(result, 1000 * self.units['kb'])
def test_unit_wrong_input(self):
- self.assertRaises(ValueError, tu.apply_units, '', self.units)
- self.assertRaises(ValueError, tu.apply_units, 'wrong input', self.units)
- self.assertRaises(ValueError, tu.apply_units, 'wrong13 input', self.units)
- self.assertRaises(ValueError, tu.apply_units, 'wrong input42', self.units)
+ self.assertRaises(
+ ValueError, tu.apply_units, '', self.units)
+ self.assertRaises(
+ ValueError, tu.apply_units, 'wrong input', self.units)
+ self.assertRaises(
+ ValueError, tu.apply_units, 'wrong13 input', self.units)
+ self.assertRaises(
+ ValueError, tu.apply_units, 'wrong input42', self.units)
with self.assertRaises(ValueError) as cm:
tu.apply_units('42 cakes', self.units)
self.assertIn('invalid unit cakes.', str(cm.exception))
+
RGX = re.compile('abcd')
+
+
class PrettyMatchTC(TestCase):
def test_known(self):