Skip to content

Commit d83692a

Browse files
committed
Merge branch 'python3'
2 parents ce723cc + 0f7a5ca commit d83692a

27 files changed

+255
-148
lines changed

.travis.install

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
PYTHON_VERSION=$(python --version 2>&1)
4+
5+
if [[ "$PYTHON_VERSION" > "Python 3" ]]; then
6+
true
7+
else
8+
pip install twisted
9+
fi

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ language: python
22
python:
33
- "2.6"
44
- "2.7"
5+
- "3.2"
6+
- "3.3"
57

68
install:
7-
- "pip install pytest Twisted coveralls pytz . --use-mirrors"
9+
- "bash .travis.install"
10+
- "pip install pytest coveralls pytz ."
811
script:
9-
- "coverage run $(which trial) test_parsley"
10-
- "coverage run -a $(which trial) ometa"
11-
- "coverage run -a $(which py.test) examples"
12+
- "coverage run $(which py.test) ."
1213
after_success:
1314
- "coveralls"
1415

examples/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
testSource = "<html<title>Yes</title><body><h1>Man, HTML is <i>great</i>.</h1><p>How could you even <b>think</b> otherwise?</p><img src='HIPPO.JPG'></img><a href='http://twistedmatrix.com'>A Good Website</a></body></html>"
2929

30-
print unwrapGrammar(TinyHTML)(testSource).apply('tag')
30+
print(unwrapGrammar(TinyHTML)(testSource).apply('tag'))
3131

3232
# The "tag" rule uses the custom label construct "^ (valid tag)".
3333
# When this rule fails, the exception raised will say

examples/minml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727

2828
testSource = "<html><title>Yes</title><body><h1>Man, HTML is <i>great</i>.</h1><p>How could you even <b>think</b> otherwise?</p><img src='HIPPO.JPG'></img><a href='http://twistedmatrix.com'>A Good Website</a></body></html>"
2929

30-
print TinyHTML(testSource).html()
30+
print(TinyHTML(testSource).html())

examples/protocol/test_netstrings.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
from twisted.test.proto_helpers import StringTransport
2-
31
import parsley
42
import pytest
53
import netstrings
64

5+
proto_helpers = pytest.importorskip('twisted.test.proto_helpers')
6+
StringTransport = proto_helpers.StringTransport
7+
8+
79
netstringGrammar = parsley.makeGrammar(netstrings.grammar, {})
810

911
def stringParserFromRule(rule):

examples/test_iso8601.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
import datetime
22
import unittest
33

4-
try:
5-
import pytz
6-
from iso8601 import DateTimeParser
7-
except ImportError:
8-
skip = 'pytz is not installed or usable'
9-
else:
10-
skip = None
4+
import pytest
115

6+
pytz = pytest.importorskip('pytz')
7+
from iso8601 import DateTimeParser
128

13-
class TestDatetimeParsing(unittest.TestCase):
14-
if skip is not None:
15-
skip = skip
169

10+
class TestDatetimeParsing(unittest.TestCase):
1711
def test_date(self):
1812
self.assertEqual(
1913
datetime.date(2001, 12, 25),

examples/test_parsley_json.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import unicode_literals
2+
13
from parsley_json import JSONParser
24
import unittest
35

@@ -17,11 +19,11 @@ def test_float(self):
1719
self.assertEqual(JSONParser("1.2E6").number(), 1.2E6)
1820

1921
def test_string(self):
20-
self.assertEqual(JSONParser('u2603').escapedUnicode(), u"\u2603")
21-
self.assertEqual(JSONParser('"foo"').string(), u"foo")
22-
self.assertEqual(JSONParser(r'"foo\n"').string(), u"foo\n")
23-
self.assertEqual(JSONParser(r'"foo\rbaz\u2603"').string(), u"foo\rbaz\u2603")
24-
self.assertEqual(JSONParser(r'"\\\/\b\"\f\t"').string(), u'\\/\b"\f\t')
22+
self.assertEqual(JSONParser('u2603').escapedUnicode(), "\u2603")
23+
self.assertEqual(JSONParser('"foo"').string(), "foo")
24+
self.assertEqual(JSONParser(r'"foo\n"').string(), "foo\n")
25+
self.assertEqual(JSONParser(r'"foo\rbaz\u2603"').string(), "foo\rbaz\u2603")
26+
self.assertEqual(JSONParser(r'"\\\/\b\"\f\t"').string(), '\\/\b"\f\t')
2527

2628
def test_literals(self):
2729
self.assertEqual(JSONParser(r'true').value(), True)

examples/trace_visualiser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from ScrolledText import ScrolledText
2-
import Tkinter as tk
1+
from tkinter.scrolledtext import ScrolledText
2+
import tkinter as tk
33

44
from trace_json import traceparse
55
from parsley_json import jsonGrammar

ometa/builder.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- test-case-name: ometa.test.test_builder -*-
22
import ast
3-
from StringIO import StringIO
3+
try:
4+
from StringIO import StringIO
5+
except ImportError:
6+
from io import StringIO
47
from types import ModuleType as module
58
import linecache, sys
69
from terml.nodes import Term, Tag, coerceToTerm
@@ -437,7 +440,7 @@ def get_source(self, name):
437440

438441

439442
def moduleFromGrammar(source, className, modname, filename):
440-
mod = module(modname)
443+
mod = module(str(modname))
441444
mod.__name__ = modname
442445
mod.__loader__ = GeneratedCodeLoader(source)
443446
code = compile(source, filename, "exec")

ometa/grammar.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"""
66
import os.path
77
import string
8-
from StringIO import StringIO
8+
try:
9+
from StringIO import StringIO
10+
except ImportError:
11+
from io import StringIO
912

1013
from terml.nodes import termMaker as t
1114
import ometa

0 commit comments

Comments
 (0)