2 new commits in pytest:
https://bitbucket.org/hpk42/pytest/commits/2383dedde452/
Changeset: 2383dedde452
User: hpk42
Date: 2014-08-01 08:13:44
Summary: Backed out changeset e57017ad86ce -- logging should not be imported
Affected #: 1 file
diff -r e57017ad86ce74ebb0e51cc0ccda1d5a240115a7 -r
2383dedde45241649cec1f2c753a4d5a1073393e testing/test_capture.py
--- a/testing/test_capture.py
+++ b/testing/test_capture.py
@@ -340,6 +340,8 @@
p = testdir.makepyfile("""
import sys
def test_something():
+ # pytest does not import logging
+ assert 'logging' not in sys.modules
import logging
logging.basicConfig()
logging.warn("hello432")
https://bitbucket.org/hpk42/pytest/commits/9e3ed0aaa45a/
Changeset: 9e3ed0aaa45a
User: hpk42
Date: 2014-08-01 10:12:53
Summary: put some imports back to function-level and streamline py2/py3
compat in one place
Affected #: 6 files
diff -r 2383dedde45241649cec1f2c753a4d5a1073393e -r
9e3ed0aaa45a92b50de88a72224f69ea22b805f0 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,9 @@
- fix issue544 by only removing "@NUM" at the end of "::" separated parts
and if the part has an ".py" extension
+- don't use py.std import helper, rather import things directly.
+ Thanks Bruno Oliveira.
+
2.6
-----------------------------------
diff -r 2383dedde45241649cec1f2c753a4d5a1073393e -r
9e3ed0aaa45a92b50de88a72224f69ea22b805f0 _pytest/__init__.py
--- a/_pytest/__init__.py
+++ b/_pytest/__init__.py
@@ -1,2 +1,2 @@
#
-__version__ = '2.6.1.dev1'
+__version__ = '2.6.1.dev2'
diff -r 2383dedde45241649cec1f2c753a4d5a1073393e -r
9e3ed0aaa45a92b50de88a72224f69ea22b805f0 _pytest/genscript.py
--- a/_pytest/genscript.py
+++ b/_pytest/genscript.py
@@ -1,9 +1,6 @@
""" generate a single-file self-contained version of pytest """
-import base64
-import pickle
import py
import sys
-import zlib
def find_toplevel(name):
@@ -33,6 +30,7 @@
return name2src
def compress_mapping(mapping):
+ import base64, pickle, zlib
data = pickle.dumps(mapping, 2)
data = zlib.compress(data, 9)
data = base64.encodestring(data)
diff -r 2383dedde45241649cec1f2c753a4d5a1073393e -r
9e3ed0aaa45a92b50de88a72224f69ea22b805f0 _pytest/junitxml.py
--- a/_pytest/junitxml.py
+++ b/_pytest/junitxml.py
@@ -2,8 +2,6 @@
Based on initial code from Ross Lawley.
"""
-import codecs
-
import py
import os
import re
@@ -11,20 +9,13 @@
import time
# Python 2.X and 3.X compatibility
-try:
- unichr(65)
-except NameError:
+if sys.version_info[0] < 3:
+ from codecs import open
+else:
unichr = chr
-try:
- unicode('A')
-except NameError:
unicode = str
-try:
- long(1)
-except NameError:
long = int
-
class Junit(py.xml.Namespace):
pass
@@ -207,11 +198,7 @@
self.suite_start_time = time.time()
def pytest_sessionfinish(self):
- if sys.version_info[0] < 3:
- logfile = codecs.open(self.logfile, 'w', encoding='utf-8')
- else:
- logfile = open(self.logfile, 'w', encoding='utf-8')
-
+ logfile = open(self.logfile, 'w', encoding='utf-8')
suite_stop_time = time.time()
suite_time_delta = suite_stop_time - self.suite_start_time
numtests = self.passed + self.failed
diff -r 2383dedde45241649cec1f2c753a4d5a1073393e -r
9e3ed0aaa45a92b50de88a72224f69ea22b805f0 _pytest/unittest.py
--- a/_pytest/unittest.py
+++ b/_pytest/unittest.py
@@ -1,7 +1,6 @@
""" discovery and running of std-library "unittest" style tests. """
from __future__ import absolute_import
import traceback
-import unittest
import sys
import pytest
@@ -12,22 +11,15 @@
from _pytest.python import transfer_markers
-def is_unittest(obj):
- """Is obj a subclass of unittest.TestCase?"""
- unittest = sys.modules.get('unittest')
- if unittest is None:
- return # nobody can have derived unittest.TestCase
+def pytest_pycollect_makeitem(collector, name, obj):
+ # has unittest been imported and is obj a subclass of its TestCase?
try:
- return issubclass(obj, unittest.TestCase)
- except KeyboardInterrupt:
- raise
- except:
- return False
-
-
-def pytest_pycollect_makeitem(collector, name, obj):
- if is_unittest(obj):
- return UnitTestCase(name, parent=collector)
+ if not issubclass(obj, sys.modules["unittest"].TestCase):
+ return
+ except Exception:
+ return
+ # yes, so let's collect it
+ return UnitTestCase(name, parent=collector)
class UnitTestCase(pytest.Class):
@@ -47,11 +39,12 @@
super(UnitTestCase, self).setup()
def collect(self):
+ from unittest import TestLoader
cls = self.obj
if not getattr(cls, "__test__", True):
return
self.session._fixturemanager.parsefactories(self, unittest=True)
- loader = unittest.TestLoader()
+ loader = TestLoader()
module = self.getparent(pytest.Module).obj
foundsomething = False
for name in loader.getTestCaseNames(self.obj):
diff -r 2383dedde45241649cec1f2c753a4d5a1073393e -r
9e3ed0aaa45a92b50de88a72224f69ea22b805f0 setup.py
--- a/setup.py
+++ b/setup.py
@@ -27,7 +27,7 @@
name='pytest',
description='pytest: simple powerful testing with Python',
long_description=long_description,
- version='2.6.1.dev1',
+ version='2.6.1.dev2',
url='http://pytest.org',
license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
Repository URL: https://bitbucket.org/hpk42/pytest/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
pytest-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-commit