Skip to content

Commit

Permalink
PY3 make it possible to run some tests in Python3
Browse files Browse the repository at this point in the history
* switch to Twisted 14.0.0 because SVN version broke twisted.log in Python 3;
* skip top-level shortcuts to make at least some tests pass;
* use PY3 compatible import of _monkeypatches.
  • Loading branch information
kmike committed Jul 2, 2014
1 parent e87dc37 commit e38e3d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
17 changes: 11 additions & 6 deletions scrapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
if sys.version_info < (2, 7):
print("Scrapy %s requires Python 2.7" % __version__)
sys.exit(1)
del sys

# Ignore noisy twisted deprecation warnings
import warnings
warnings.filterwarnings('ignore', category=DeprecationWarning, module='twisted')
del warnings

# Apply monkey patches to fix issues in external libraries
import _monkeypatches
from . import _monkeypatches
del _monkeypatches

# WARNING: optional_features set is deprecated and will be removed soon. Do not use.
Expand Down Expand Up @@ -53,7 +52,13 @@
optional_features.add('http11')

# Declare top-level shortcuts
from scrapy.spider import Spider
from scrapy.http import Request, FormRequest
from scrapy.selector import Selector
from scrapy.item import Item, Field
if sys.version_info[0] == 2:
# Top-level shortcuts are not ready for Python 3 (like most of Scrapy);
# skip them here to make at least some parts of Scrapy
# importable in Python 3.
from scrapy.spider import Spider
from scrapy.http import Request, FormRequest
from scrapy.selector import Selector
from scrapy.item import Item, Field

del sys
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ commands =
[testenv:py33]
basepython = python3.3
deps =
svn+svn://svn.twistedmatrix.com/svn/Twisted/trunk#egg=Twisted
; svn+svn://svn.twistedmatrix.com/svn/Twisted/trunk#egg=Twisted
twisted >= 14.0.0
lxml>=3.2.4
pyOpenSSL>=0.13.1
cssselect>=0.9
Expand Down

0 comments on commit e38e3d2

Please sign in to comment.