Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
188bdbca
Commit
188bdbca
authored
Mar 21, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disable some f-string formatting tests that give "suboptimal" results in Py2.6
parent
8e1114a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
9 deletions
+28
-9
tests/run/test_fstring.pyx
tests/run/test_fstring.pyx
+28
-9
No files found.
tests/run/test_fstring.pyx
View file @
188bdbca
...
...
@@ -6,9 +6,11 @@ import ast
import
types
import
decimal
import
unittest
import
contextlib
import
sys
IS_PY2
=
sys
.
version_info
[
0
]
<
3
IS_PY26
=
sys
.
version_info
[:
2
]
<
(
2
,
7
)
from
Cython.Build.Inline
import
cython_inline
from
Cython.TestUtils
import
CythonTest
...
...
@@ -59,8 +61,23 @@ class TestCase(CythonTest):
first
=
stripped_first
.
decode
(
'unicode_escape'
)
super
(
TestCase
,
self
).
assertEqual
(
first
,
second
,
msg
)
if
IS_PY26
:
@
contextlib
.
contextmanager
def
assertRaises
(
self
,
exc
):
try
:
yield
except
exc
:
pass
else
:
assert
False
,
"exception '%s' not raised"
%
exc
def
assertIn
(
self
,
value
,
collection
):
self
.
assertTrue
(
value
in
collection
)
def
test__format__lookup
(
self
):
if
IS_PY2
:
if
IS_PY26
:
return
elif
IS_PY2
:
raise
unittest
.
SkipTest
(
"Py3-only"
)
# Make sure __format__ is looked up on the type, not the instance.
...
...
@@ -275,11 +292,12 @@ f'{a * x()}'"""
width
=
10
precision
=
4
value
=
decimal
.
Decimal
(
'12.34567'
)
self
.
assertEqual
(
f'result:
{
value
:
{
width
}
.
{
precision
}}
'
,
'result: 12.35'
)
self
.
assertEqual
(
f'result:
{
value
:
{
width
!
r
}
.
{
precision
}}
'
,
'result: 12.35'
)
self
.
assertEqual
(
f'result:
{
value
:
{
width
:
0
}
.
{
precision
:
1
}}
'
,
'result: 12.35'
)
self
.
assertEqual
(
f'result:
{
value
:
{
1
}{
0
:
0
}
.
{
precision
:
1
}}
'
,
'result: 12.35'
)
self
.
assertEqual
(
f'result:
{
value
:
{
1
}{
0
:
0
}
.
{
precision
:
1
}}
'
,
'result: 12.35'
)
if
not
IS_PY26
:
self
.
assertEqual
(
f'result:
{
value
:
{
width
}
.
{
precision
}}
'
,
'result: 12.35'
)
self
.
assertEqual
(
f'result:
{
value
:
{
width
!
r
}
.
{
precision
}}
'
,
'result: 12.35'
)
self
.
assertEqual
(
f'result:
{
value
:
{
width
:
0
}
.
{
precision
:
1
}}
'
,
'result: 12.35'
)
self
.
assertEqual
(
f'result:
{
value
:
{
1
}{
0
:
0
}
.
{
precision
:
1
}}
'
,
'result: 12.35'
)
self
.
assertEqual
(
f'result:
{
value
:
{
1
}{
0
:
0
}
.
{
precision
:
1
}}
'
,
'result: 12.35'
)
self
.
assertEqual
(
f'
{
10
:
#
{
1
}
0
x
}
'
,
' 0xa'
)
self
.
assertEqual
(
f'
{
10
:
{
"#"
}
1
{
0
}{
"x"
}}
'
,
' 0xa'
)
self
.
assertEqual
(
f'
{
-
10
:
-
{
"#"
}
1
{
0
}
x
}
'
,
' -0xa'
)
...
...
@@ -584,9 +602,10 @@ f'{a * x()}'"""
def
test_conversions
(
self
):
self
.
assertEqual
(
f'
{
3.14
:
10.10
}
'
,
' 3.14'
)
self
.
assertEqual
(
f'
{
3.14
!
s
:
10.10
}
'
,
'3.14 '
)
self
.
assertEqual
(
f'
{
3.14
!
r
:
10.10
}
'
,
'3.14 '
)
self
.
assertEqual
(
f'
{
3.14
!
a
:
10.10
}
'
,
'3.14 '
)
if
not
IS_PY26
:
self
.
assertEqual
(
f'
{
3.14
!
s
:
10.10
}
'
,
'3.14 '
)
self
.
assertEqual
(
f'
{
3.14
!
r
:
10.10
}
'
,
'3.14 '
)
self
.
assertEqual
(
f'
{
3.14
!
a
:
10.10
}
'
,
'3.14 '
)
self
.
assertEqual
(
f'
{
"a"
}
'
,
'a'
)
self
.
assertEqual
(
f'
{
"a"
!
r
}
'
,
"'a'"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment