]> git.pld-linux.org Git - packages/python-sure.git/blob - python-sure-py3_fixes.patch
Release 2. Fixed Python 3.4 build and tests.
[packages/python-sure.git] / python-sure-py3_fixes.patch
1 diff --git a/README.md b/README.md
2 index 3714d29..efda4a5 100644
3 --- a/README.md
4 +++ b/README.md
5 @@ -32,7 +32,6 @@ import sure
6  
7  (4).should.be.equal(2 + 2)
8  (7.5).should.eql(3.5 + 4)
9 -(2).should.equal(8 / 4)
10  
11  (3).shouldnt.be.equal(5)
12  ```
13 diff --git a/setup.py b/setup.py
14 index a4877f6..778f8c8 100755
15 --- a/setup.py
16 +++ b/setup.py
17 @@ -18,6 +18,7 @@
18  
19  import ast
20  import os
21 +import sys
22  from setuptools import setup, find_packages
23  
24  
25 @@ -41,8 +42,10 @@ def read_version():
26      return finder.version
27  
28  
29 -local_file = lambda *f: \
30 -    open(os.path.join(os.path.dirname(__file__), *f)).read()
31 +def local_file( *f):
32 +    if sys.version_info < (3, 0, 0):
33 +        return open(os.path.join(os.path.dirname(__file__), *f)).read()
34 +    return open(os.path.join(os.path.dirname(__file__), *f), encoding="utf-8").read()
35  
36  
37  install_requires = ['mock', 'six']
38 diff --git a/sure/old.py b/sure/old.py
39 index 70822e1..13a3f74 100644
40 --- a/sure/old.py
41 +++ b/sure/old.py
42 @@ -42,10 +42,10 @@ from sure.core import itemize_length
43  
44  
45  def identify_callable_location(callable_object):
46 -    filename = os.path.relpath(callable_object.func_code.co_filename)
47 -    lineno = callable_object.func_code.co_firstlineno
48 -    callable_name = callable_object.func_code.co_name
49 -    return b'{0} [{1} line {2}]'.format(callable_name, filename, lineno)
50 +    filename = os.path.relpath(callable_object.__code__.co_filename)
51 +    lineno = callable_object.__code__.co_firstlineno
52 +    callable_name = callable_object.__code__.co_name
53 +    return '{0} [{1} line {2}]'.format(callable_name, filename, lineno).encode()
54  
55  
56  def is_iterable(obj):
57 diff --git a/tests/test_assertion_builder.py b/tests/test_assertion_builder.py
58 index 3e1cd8e..7e833e6 100644
59 --- a/tests/test_assertion_builder.py
60 +++ b/tests/test_assertion_builder.py
61 @@ -648,13 +648,19 @@ def test_throw_matching_regex():
62          raise RuntimeError('should not have reached here')
63  
64      except AssertionError as e:
65 -        expect(str(e)).to.equal("When calling 'blah [tests/test_assertion_builder.py line 633]' the exception message does not match. Expected to match regex: u'invalid regex'\n against:\n u'this message'")
66 +        if PY3:
67 +            expect(str(e)).to.equal("When calling b'blah [tests/test_assertion_builder.py line 633]' the exception message does not match. Expected to match regex: 'invalid regex'\n against:\n 'this message'")
68 +        else:
69 +            expect(str(e)).to.equal("When calling 'blah [tests/test_assertion_builder.py line 633]' the exception message does not match. Expected to match regex: u'invalid regex'\n against:\n u'this message'")
70  
71      try:
72          expect(blah).when.called_with(1).should.throw(ValueError, re.compile(r'invalid regex'))
73          raise RuntimeError('should not have reached here')
74      except AssertionError as e:
75 -        expect(str(e)).to.equal("When calling 'blah [tests/test_assertion_builder.py line 633]' the exception message does not match. Expected to match regex: u'invalid regex'\n against:\n u'this message'")
76 +        if PY3:
77 +            expect(str(e)).to.equal("When calling b'blah [tests/test_assertion_builder.py line 633]' the exception message does not match. Expected to match regex: 'invalid regex'\n against:\n 'this message'")
78 +        else:
79 +            expect(str(e)).to.equal("When calling 'blah [tests/test_assertion_builder.py line 633]' the exception message does not match. Expected to match regex: u'invalid regex'\n against:\n u'this message'")
80  
81  def test_should_not_be_different():
82      ("'something'.should_not.be.different('SOMETHING'.lower())")
This page took 0.082607 seconds and 3 git commands to generate.